Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Location
    Manchester,TN, Venezuela
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    outlook and access (2000/sr-1)

    I want to send a single email to a list of email addresses that exists in an Access table/query. Does anyone know how I can automate this process?

  2. #2
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: outlook and access (2000/sr-1)

    Here's the basic framework that should get you started:
    <font face="Georgia">
    Public Sub SendMessage(strNameTable As String, strBody As String)

    Dim Outlook As Object
    Dim myItem As Object
    Dim blnNeedToQuit As Boolean
    Dim rstNames As Recordset

    Set rstNames = CurrentDb.OpenRecordset(strNameTable, dbOpendynaset)

    ' Reference Outlook application object
    On Error Resume Next
    Set Outlook = GetObject(, "Outlook.Application")

    ' If Outlook isn't running, then create an instance of it
    blnNeedToQuit = False
    If Err Then
    Set Outlook = CreateObject("Outlook.Application")
    blnNeedToQuit = True
    End If
    On Error GoTo 0

    Set myItem = Outlook.CreateItem(olMailItem)

    Do While Not rstNames.EOF
    myItem.Recipients.Add rstNames!EMailAddress
    rstNames.MoveNext
    Loop

    myItem.Subject = "Message Title Text"
    myItem.Body = strBody

    On Error Resume Next
    myItem.Send
    On Error GoTo 0

    If blnNeedToQuit Then Outlook.Quit

    End Sub
    </font face=georgia>
    In VBA be sure to specify references to the Microsoft DAO library (latest version; probably 3.6) and the Microsoft Outlook 9.0 Object Library using Tools...References.

    Hope this helps.

  3. #3
    New Lounger
    Join Date
    Jul 2002
    Location
    Manchester,TN, Venezuela
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: outlook and access (2000/sr-1)

    I'm sorry I've been so slow to respond to your post, but your post was exactly what I needed to get me started. Thank you very much!
    <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •