Note: If you need to send out a massive amount of emails this code is not for you, instead we recommend FMS’s Total Access Emailer.
Note 2: You must add a reference to Outlook in your Access project in order for this code to work, if you need an alternate version that does not require it then look at the next section of this post below:
Dim objOutlook As Outlook.Application
Dim objOutLookMsg As Outlook.MailItem
Dim strBody as String
strBody = "Insert you body message here."
Set objOutlook = New Outlook.Application
Set objOutLookMsg = objOutlook.CreateItem(0)
With objOutLookMsg
.To = "w@what_Ever.com"
.CC = "any@what_ever.com"
.Subject = "Enter Your Subject Here"
.Body = strBody
.Send
End With
Code without a reference to Outlook:
Dim objOutlook As Object
Dim objOutLookMsg As Object
Dim strBody as String
strBody = "Insert you body message here."
Set objOutlook = CreateObject("Outlook.Application")
Set objOutLookMsg = objOutlook.CreateItem(0)
With objOutLookMsg
.To = "w@what_Ever.com"
.CC = "any@what_ever.com"
.Subject = "Enter Your Subject Here"
.Body = strBody
.Send
End With
If the e-mail is simple then its much lighter to use CDO.sys
You can check it first if u have it in ur system and use it to send simple e-mails.
Thanks for sharing!