Merging Access Contact Info Fields into Outlook VBA

  • Thread starter Thread starter jfriand
  • Start date Start date
J

jfriand

I am trying to use the code below but would like to use an Access table
to feed the 120 individual "email", "subject", "body" and "attachment"
that I need.

What would be the easiest solution to not have to copy this code for my
120 contacts?

Any help greatly appreciated. Thank you in advance.

--------------------------------------------------
On Error GoTo Error_Handler
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = "Email"
.Subject = "Subject"
.body = "Body"
.Attachments.Add "attachment"
.Send
' .ReadReceiptRequested
End With

Exit_Here:
Set objOutlook = Nothing
Exit Sub
Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here
End Sub
-------------------------------------------
 
Probably best posted to an Outlook or Access programming group - you will
likely get more people who are able to help as they tend to hang out there
rather than in a general group like this one.

--
Milly Staples [MVP - Outlook]

Post all replies to the group to keep the discussion intact. Due to
the (insert latest virus name here) virus, all mail sent to my personal
account will be deleted without reading.

After furious head scratching, (e-mail address removed) asked:

| I am trying to use the code below but would like to use an Access
| table to feed the 120 individual "email", "subject", "body" and
| "attachment" that I need.
|
| What would be the easiest solution to not have to copy this code for
| my 120 contacts?
|
| Any help greatly appreciated. Thank you in advance.
|
| --------------------------------------------------
| On Error GoTo Error_Handler
| Dim objOutlook As Outlook.Application
| Dim objEmail As Outlook.MailItem
| Set objOutlook = CreateObject("Outlook.application")
| Set objEmail = objOutlook.CreateItem(olMailItem)
|
| With objEmail
| .To = "Email"
| .Subject = "Subject"
| .body = "Body"
| .Attachments.Add "attachment"
| .Send
| ' .ReadReceiptRequested
| End With
|
| Exit_Here:
| Set objOutlook = Nothing
| Exit Sub
| Error_Handler:
| MsgBox Err & ": " & Err.Description
| Resume Exit_Here
| End Sub
| -------------------------------------------
 
Back
Top