Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.
Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Create the Outlook session. Set objOutlook = CreateObject("Outlook.Application", localhost) 'Set objOutlook = Outlook.Application ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. Substitute ' your names here. Set objOutlookRecip = .Recipients.Add("email@example.com") '<--Recipient's name or email address objOutlookRecip.Type = olTo ' Add the CC recipient(s) to the message. 'Set objOutlookRecip = .Recipients.Add("CC Recipient Name") 'objOutlookRecip.Type = olCC ' Set the Subject, Body, and Importance of the message. .Subject = "Blah Blah Blah" '<--Subject .Body = "Dear Tom" & vbCr & vbCr '<--Email Body text. .Importance = olImportanceHigh 'High importance 'Add attachments to the message. 'Set objOutlookAttach = .Attachments.Add("C:\Earth.jpg") '<-- Add as many attachments as you need here. 'Set objOutlookAttach = .Attachments.Add("C:\TextFile.txt") ' Resolve each Recipient's name. For Each objOutlookRecip In .Recipients If Not objOutlookRecip.Resolve Then objOutlookMsg.Display End If Next 'Send email without viewing it. '.Send 'Dispay email before sending. .Display End With 'Cleanup Code Set objOutlookMsg = Nothing Set objOutlook = Nothing Set objOutlookRecip = Nothing Set objOutlookAttach = Nothing End Sub
Join the community of 500,000 technology professionals and ask your questions.