Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mass emailings

Status
Not open for further replies.

videoguyz

Technical User
Oct 8, 2001
1
US
How do I link my emails from my forms to send out mass emailings from Outlook.
 
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: & Chr(10) & Chr(13) _
& "Phone: (909)244-4275" & Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& Chr(10) & Chr(13) _
& "This message was automated using MS Access 2000 (ADO) and MS Outlook 2000"
.Importance = olImportanceHigh 'High importanc
'Add attachments to the message
Set objOutlookAttach = .Attachments.Add("c:\Tyrone_Lumley.zip")
.Save
.Send
End With
rst.MoveNext
With rstSent
.AddNew
.Fields(0) = rst.Fields(0)
.Fields(1) = Date
.Fields(2) = "Unsolicited"
End With
Loop
Set objOutlook = Nothing
End Sub

You can modify the sql statements (strSQL) and the body of the message as you see fit.... Tyrone Lumley
augerinn@gte.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top