Just did it last night. I have a table called tblJobProspects, which holds E-mails. I have another table, tblSent, to keep track of who I sent to. The following code will perform a mass mailing.
Public Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim rst As ADODB.Recordset
Dim rstSent As ADODB.Recordset
Dim strSQL
Dim strSQLsent
strSQL = "SELECT tblJobProspects.Email, tblJobProspects.FName, tblJobProspects.Subject FROM tblJobProspects WHERE (((tblJobProspects.Subject) Is Null))"
strSQLsent = "Select * FROM tblSent"
Set rst = New ADODB.Recordset
Set rstSent = New ADODB.Recordset
rst.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rstSent.Open strSQLsent, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
'Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application"
rst.MoveLast
rst.MoveFirst
Do While Not rst.EOF
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
'Create the message.
With objOutlookMsg
'Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(rst.Fields(0).Value)
objOutlookRecip.Type = olTo
If IsNull(rst.Fields(1)) Then
strContact = "Hiring Professional"
Else
strContact = rst.Fields(1)
End If
'Set the Subject, Body, and Importance of the message.
.Subject = "MIS Professional Available Immediately"
.BODY = "Dear: " & strContact _
& Chr(10) & Chr(13) _
& "I had not been affected by the 9/11/2001 incident until recently." _
& " However, as of 5 Oct 2001, I was laid off with approximately 20% of the total" _
& " workforce at Tempo/Textron in Vista California." & Chr(10) & Chr(13) _
& "The good news is that a talented, well rounded Computer Professional is" _
& " now available to provide innovative solutions to you or your client(s)." & Chr(10) & Chr(13) _
& "Please find attached a zipped copy of my resume for your review" & Chr(10) & Chr(13) _
& "I can be contacted by any of the following means:" & Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& "E-Mail: augerinn@gte.net" & Chr(10) & Chr(13) _
& "WebPage:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.