Microsoft Office Tutorials and References
In Depth Information
Putting It All Together
‘Create your MailItem email object.
.To = “firstname.lastname@example.org”
.CC = “email@example.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
‘Release object variables from system memory.
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objInbox = Nothing
Set objMailItem = Nothing
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.