Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PAG PAG is offline
external usenet poster
 
Posts: 14
Default VBA code to email active work book

Hi,

Is there some VBA code that I can use to be able to add text "Please provide
the accrued interest on the attached interfund trades. Thank you" to the body
of my email?

Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" &
vbNewLine & _
"be no VBA code in the file you send. Save the" &
vbNewLine & _
"file first as xlsm and then try the macro again.",
vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail ", _
"Interfund Trade Accrued Interest"
On Error GoTo 0

End Sub


Thank you,

Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default VBA code to email active work book

On May 19, 1:11*pm, PAG wrote:
Hi,

Is there some VBA code that I can use to be able to add text "Please provide
the accrued interest on the attached interfund trades. Thank you" to the body
of my email?

Dim wb As Workbook
* * Set wb = ActiveWorkbook

* * If Val(Application.Version) = 12 Then
* * * * If wb.FileFormat = 51 And wb.HasVBProject = True Then
* * * * * * MsgBox "There is VBA code in this xlsx file, there will" &
vbNewLine & _
* * * * * * * * * *"be no VBA code in the file you send. Save the" &
vbNewLine & _
* * * * * * * * * *"file first as xlsm and then try the macro again.",
vbInformation
* * * * * * Exit Sub
* * * * End If
* * End If

* * On Error Resume Next
* * wb.SendMail ", _
* * * * * * * * "Interfund Trade Accrued Interest"
* * On Error GoTo 0

* End Sub

Thank you,

Peter



With SendMail it is not possible to add text to the body of the
email. However, if you use CDO instead, you could do that. Below is
a simple example of doing this - adding an attachment and putting text
in the body of the email. Watch for word-wrap.

Jennifer


Dim wshnet
Dim compname

Set wshnet = CreateObject("wscript.network")
compname = wshnet.computername
Set iConf = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/
smtpserver") = "mail" '"dev.smtp.wbhq.com"
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/
smtpport") = 25
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/
sendusing") = 2
iConf.Fields.Update

iMsg.Configuration = iConf
iMsg.From = "
iMsg.To = "
imsg.AddAttachment "C:\test.txt"
iMsg.Subject = "subject"
iMsg.TextBody = "this is a test"
iMsg.Send
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Email work book. Melisa Hutchins Excel Discussion (Misc queries) 0 May 13th 10 03:41 PM
How do I email one sheet from within an excell work book file Marguerite Excel Worksheet Functions 1 April 29th 08 05:06 PM
Work book event code help (re Bob Phillips) Dingy101 Excel Programming 1 November 8th 07 02:49 AM
searching by number or code ina work book justsomeguy Excel Discussion (Misc queries) 0 February 19th 07 08:55 PM
Please Help!!! How Do I Specify A particualr work book to execute code on MrGreenFingas Excel Programming 3 September 1st 05 12:08 PM


All times are GMT +1. The time now is 08:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"