View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
kathryn kathryn is offline
external usenet poster
 
Posts: 12
Default Sending Mail from Excel: Body Text

Hello ~

I am mailing a workbook and would like to have the email
body included in the code. Here is what I have currently
(from Ron de Bruin's excellent resource) and it is working
fine for Recepient (I am adding from Outlook address book)
and Subject.


Sub mcrMail_workbook()
'
' mcrMail_workbook()
' Macro recorded 12/1/2003 by
'

'
ActiveWorkbook.SendMail "", _
"Your 2004 Flexible Benefit
Election Form"
End Sub

Does anyone know how to add the body to the code? Ron
also has this but it is not working for me.

Sub Mail_workbook_Outlook()
'This example send the last saved version of the
Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'In Excel 97 use ActiveWorkbook.Path & "\" &
ActiveWorkbook.Name
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Thank you!