Originally posted by mikezcg
I have 30 emails i have to send out each week (using outlook)
I would like to program in the user address' and the name of the files (both email and filenames are constant) and also add a constant subject and msg body.
I have sent access repts but not such a complete task as the one @ hand.
I used following code once in Excel.
I suppose in Access it's quite the same.
Private Sub createEmail()
Dim myOutlook As Outlook.Application
Dim myMail As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Dim myDistributionList As AddressEntry
Set myOutlook = CreateObject("Outlook.Application")
Set myMail = myOutlook.CreateItem(olMailItem)
Set myAttachments = myMail.Attachments
myAttachments.Add "C:\myExcel-file",olByValue, 1
Set myDistributionList = myOutlook.GetNamespace("MAPI").AddressLists("Contacts").AddressEntries("myRecipientsName")
.To = myDistributionList
.Subject = "My subject"
Set myOutlook = Nothing
Set myMail = Nothing
Set myAttachments = Nothing