Emailing from Excel

  • Thread starter Thread starter pvp
  • Start date Start date
P

pvp

Is it possible to enter Outlook Express from Excel, using
a bunch of cell in the spreadsheet as the TO addresses for
the email. And other cells as Subject, CC, ...
And then fill in the email and add attachments in Outlook
before sending it.

Thanks
 
Sub EmailFromExcel()

Dim olApp As Outlook.Application, olMail As
Outlook.MailItem
Dim Rng As Range
Dim objOLAttach As Outlook.Attachment

iPath = 'YOUR FILE PATH GO'S HERE

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = Range("to_addresses").Value 'this is a
cell reference for your 'To' email addresses
olMail.CC Range("cc_addresses").Value 'this is a cell
reference for your 'CC' email addresses
olMail.BCC = Range("bcc_addresses").Value 'this is a
cell reference for your 'BCC' email addresses


'email subject here
olMail.Subject = "REPLACE THIS TEXT WITH YOUR EMAIL
SUBJECT"

'main message here
olMail.Body = "Dear ExcelAid" _
& vbCrLf & vbCrLf & "REPLACE THIS TEXT WITH
THE BODY TEXT FOR YOUR EMAIL." _
& vbCrLf & vbCrLf & "Regards," _
& vbCrLf & vbCrLf & "ExcelAid," _
& vbCrLf & "mailto:[email protected]"

'attachment
olMail.Attachments.Add iPath 'this will attach the
file you declared earlier.

olMail.Display 'DISPLAYS THE EMAIL

olMail.Send 'WILL AUTO SEND THE EMAIL

End Sub

You will need to have 9.0 Microsoft Outlook Object Library
checked within VB. The 9.0 may vary depending on the
version of Excel you are using.


regards

Kerry Bennett
www.excelaid.com
 
Back
Top