VBA Code to put in Access that will send an Email with Attachments

  • Thread starter Thread starter jon.ingram
  • Start date Start date
J

jon.ingram

I am wondering if anyone out there has some VB code that I can put in
access that will open outlook email attach 2 excel files and address
it to a distribution list I have saved in outlook.

This would be huge....thanks.
 
That's pretty straightforward Outlook automation:

On Error Resume Next
Set ol = GetObject(, "Outlook.Application")
If ol Is Nothing Then
Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
' log on with desired profile
ng.Logon "Outlook Settings", "", False, False
End If
Set msg = ol.CreateItem(0)
msg.To = "name of DL"
msg.Attachments.Add "C:\excelfile1.xls"
msg.Attachments.Add "C:\excelfile2.xls"
msg.Display

For more basics, see http://www.outlookcode.com/d/vb.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top