Unanswered: Sending Emails using addresses listed on Access
I'm adding the finishing touches on my contacts database. I've seemed to run into a problem. I can't figure out how to extract email addresses from my search form results and import them into outlook. I believe that this involves some sort of loop function.
Not sure what your trying to add email addresses to Outlook, or use Outlook to email users from your recordset. I have used the following code to email multiple users.
Public Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim i As Integer, j As Integer
Dim dbs As Database, rst As Recordset
Dim strSQL As String, buff As String
' Create the Outlook session and empty message
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
strSQL = "SELECT EmailAddress FROM source;"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
For j = 1 To rst.RecordCount
Set objOutlookRecip = .Recipients.Add(rst!EmailAddress)
objOutlookRecip.Type = olTo
.Subject = "Subject line"
.Body = "Whatever you want to say"
.Importance = olImportanceNormal 'Normal importance
Set rst = Nothing
Set dbs = Nothing
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
The search results would represent a recordset, so no I don't believe it would matter.
I am trying to do something similar from Exchange to SQL, so not sure if I would be able to help with populating Outlook directly from Access.
I do know that for my application, I need to use Microsoft DB OLE Provider for Exchange to link directly to the contacts in Exchange.
I also know that a link to Outlook can be setup in Access, but it uses the local machines profile. This wasn't a good solution for me in a multi-user environment.