Microsoft Office Tutorials and References
In Depth Information
E-mailing from Excel with Outlook
Set oApp = CreateObject("Outlook.Application")¶
Set oMail = oApp.CreateItem(0) 'olMailItem = 0¶
With oMail¶
'Hard code To property¶
.To = "test@HolyMacroBooks.com"¶
'User input To property¶
.To = Range("B1").Value¶
'Hard code CC property¶
.CC = "test@HolyMacroBooks.com"¶
'User input CC property¶
.CC = Range("B2").Value¶
'Hard code Read Receipt Requested property¶
.ReadReceiptRequested = True¶
'User input Read Receipt Requested property¶
.ReadReceiptRequested = Range("B3").Value¶
'Hard code Subject property¶
.Subject = "File for " & Format$(Date, "mmm dd, yyy")¶
'User input Subject property¶
.Subject = Range("B4").Value¶
'Hard code Body property¶
.Body = "Hi there"¶
'User input Body property¶
.Body = Range("B5").Value¶
'Hard code Sensitivity property¶
.Sensitivity = 3 'olConfidential = 3¶
'Set attachment¶
.Attachments.Add WB.FullName¶
'Hard code importance¶
''olImportanceHigh = 2¶
.Importance = 2¶
'Send directly (remove apostrophe on line below to activate)¶
'.Send¶
'Display it¶
.Display¶
End With¶
If SendSheetOnly Then¶
WB.ChangeFileAccess Mode:=xlReadOnly¶
Kill WB.FullName¶
WB.Close SaveChanges:=False¶
End If¶
exiting:¶
'Restore screen updating¶
Application.ScreenUpdating = True¶
'destroy variables and restore memory¶
Set oMail = Nothing¶
Set oApp = Nothing¶
End Sub¶
Exl
Search JabSto ::




Custom Search