VBA code to send email.

  • Thread starter Thread starter Capinvest
  • Start date Start date
C

Capinvest

Does anyone know how to code Access to send an email when
a certain condition is met. I am trying to automate our
billing system and would like access to send an email to a
specific address every time a client needs a bill sent to
them. If anyone can help by supplying a generic code, it
would be greatly appreciated.
 
Dear Capinvest,
Begin to set a Refrence to Microsoft Outlook Object
Then can you program for example:

Private Sub cmdSendMail_Click()
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
With objOutlook.CreateItem(olMailItem)
.To = "(e-mail address removed)"
.Subject = "Note this message ..."
.Body = "This is what I have to say..."
.SentOnBehalfOfName = "The senders name"
.Importance = olImportanceHigh
.Sensitivity = olConfidential
.Send
End With
Set objOutlook = Nothing
End Sub


For more stuff:

See the Microsoft Knowledge Base Article - Q318881
How To Use a Recordset to Send Outlook E-Mail to Multiple
Recipients
http://support.microsoft.com/default.aspx?scid=kb;en-
us;Q318881

And:

http://www.granite.ab.ca/access/email.htm

Enjoy,
Arni Laugdal,
MS Office 2000 Master Instructor,
www.til.is/msaccess
 
Thanks for your help.
-----Original Message-----
Dear Capinvest,
Begin to set a Refrence to Microsoft Outlook Object
Then can you program for example:

Private Sub cmdSendMail_Click()
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
With objOutlook.CreateItem(olMailItem)
.To = "(e-mail address removed)"
.Subject = "Note this message ..."
.Body = "This is what I have to say..."
.SentOnBehalfOfName = "The senders name"
.Importance = olImportanceHigh
.Sensitivity = olConfidential
.Send
End With
Set objOutlook = Nothing
End Sub


For more stuff:

See the Microsoft Knowledge Base Article - Q318881
How To Use a Recordset to Send Outlook E-Mail to Multiple
Recipients
http://support.microsoft.com/default.aspx?scid=kb;en-
us;Q318881

And:

http://www.granite.ab.ca/access/email.htm

Enjoy,
Arni Laugdal,
MS Office 2000 Master Instructor,
www.til.is/msaccess

.
 
Back
Top