Bulk Email From Access

E

Eoin McGlynn

I am try to send the same mail to multiple people from access. There are 2
parts:

1. Select the mail template

Private Sub cmdBrowse_Click()

'Filter the Open dialog to Outlook template files
dlgCommon.Filter = "*.oft"

'Display the Open dialog
dlgCommon.ShowOpen

'Populate txtTemplate with the selected file
Me.txtTemplate = dlgCommon.FileName
End Sub

I seem to have a problem at the dlgcommon.filter stage and can't figure you
why?

2. Send the mail

Option Compare Database
Option Explicit
Private mobjOutlook As Outlook.Application
Private mobjCurrentMessage As Object

Sub Email_Click()

' Customize a message for each contact and then send or save the message
Dim intMessageCount As Integer

'Declare and instantiate a recordset object
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

'Open a recordset based on the result of qryBulkMail
rst.Open "qryBulkMail", CurrentProject.Connection
intMessageCount = 0

Set mobjOutlook = CreateObject("Outlook.Application")

' Loop through the contacts in the open folder
Do Until rst.EOF
' Check that the contact has an email address.
If rst("EmailAddress") <> "" Then

'Create a mail item based on the selected template
Set mobjCurrentMessage =
mobjOutlook.CreateItemFromTemplate(Me.txtTemplate)

'Add the email address as the recipient for the message
mobjCurrentMessage.Recipients.Add rst("EmailAddress")

' Send the message
mobjCurrentMessage.Send

intMessageCount = intMessageCount + 1
End If
rst.MoveNext
Loop

' Write the number of messages created to the worksheet
MsgBox intMessageCount & " Messages Sent"
End Sub

HEre I have an error @ rst.Open "qryBulkMail",
 
E

Eoin McGlynn

Embarrassingly I forget to add the active-x control for the dialog box…

But I still have the error send the mail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top