Question Access and Outlook

dwilliams

Registered User.
Local time
Today, 16:21
Joined
Jul 29, 2006
Messages
22
So now I have 500 or so customers and I want to send them all and email (I have all their email addresses in the table). can I get them all into the TO field an Outlook message?

I have Office 2010 on Win XP Pro SP3

Thanks

Dave

PS I have checked some previous answers and on other boards but there appears to be an element of VBA involved which I am not familiar with.
 
For sending emails from Access through Outlook, the simplest option is DoCmd.SendObject. Just fill in the arguments. There are limitations on it though, including a 255 maximum character limit for the message, not being able to choose your From address, etc.

A more powerful approach is to use office automation by calling an Outlook object. You can read up about that here: http://msdn.microsoft.com/en-us/library/office/ee208547(v=office.12).aspx

Finally, there's a way to email without using Outlook using CDO. This is the most complicated method, but also my favorite because it's the most reliable way of automatically sending out emails. If you've tried either of the previous two methods, you'll notice a security prompt pop up. Unfortunately, I don't have time to explain it right now, but you should be able to find it in Google.

As for populating your To field, you would just loop through your table and append each address with a ";" inbetween. Something like:
Code:
    Dim SendTo As String
    SendTo = ""

    Dim r As DAO.Recordset
    'Open a recordset for your email addresses in your contact table
    Set r = CurrentDb.OpenRecordset("SELECT [Emails] FROM [ContactTable]")

    If Not (r.EOF And r.BOF) Then
        Do Until r.EOF = True
            If Not IsNull(r!Emails) Then
                SendTo = SendTo & r!Emails & "; "
            End If
            r.MoveNext
        Loop

        'Remove the extra ";" at the end
        SendTo = left(SendTo, Len(SendTo) - 1)
    End If

    r.Close
    Set r = Nothing

    DoCmd.SendObject acSendNoObject,,, SendTo,,,"Test Subject","Test Message",True
 

Users who are viewing this thread

Back
Top Bottom