Microsoft Office Tutorials and References
In Depth Information
Putting It All Together
‘Create your MailItem email object.
With objMailItem
.To = “someone@somewhere.com”
.CC = “anyone@anywhere.com”
.Subject = “Testing my email code”
.Importance = 1
.Body = _
“Hello, attached is a workbook, and below is a list of employee names.” _
& Chr(10) & Chr(10) & strtext
.Attachments.Add “C:\Your\File\Path\YourFileName.xlsx”
.Display
End With
‘Release object variables from system memory.
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objInbox = Nothing
Set objMailItem = Nothing
End Sub
figurE 28-2
Before testing the ExampleEmail macro, you’ll probably need to modify the folder
path and filename of the attachment. If you want to test the macro without
attaching a file, you can simply delete or comment out the Attachments.Add statement.
 
Search JabSto ::




Custom Search