Send Mail From access (VBA Code)
Okay, after many attempts I managed to create options for sending email via Access:
Is necessary to:
1. Outlook program installed on your computer.
2. Add in the "References" the Type "Microsoft Outlook 12.0 object library" ... See More
To Send a single email:
Dim olApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = "Your Mail"
.Subject = "Subject"
.HTMLBody = "Text"
MsgBox "Operation completed successfully"
Thanks and good luck everyone!!
Last edited by shmulikharel; 05-27-2010 at 12:23 PM.