Results 1 to 3 of 3
  1. #1
    agent- is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    45

    VBA to use Query email addresses in TO: of Outlook

    Hello,

    I have a query that gathers email lists based on whether or not the record is part of the distribution list. I need to be able to either:

    1. Open outlook new mail message with the To: field populated with email address, followed by ;

    OR

    2. Create a listing of the email addresses, with each followed by ; and then I can do the rest.

    #1 would be an ideal solution, but I would be satisfied with #2

    Here is what I am thinking for the VBA for #2

    Dim Outlook

    Dim rs As Recordset
    Set rs = qryPipeline

    Do While Not rs.EOF
    Outlook = Outlook + emailaddress + ;


    rs.movenext
    Loop

    Me.Text0 = Outlook

    Then I would set up the email procedure to have this sent every Sunday since the newsletter will be sent monday morning If I use #2.

    Help would be greatly appreciated! I'm still researching

  2. #2
    agent- is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    45
    Was able to find out how to open Outlook from Access. Now I just need the string for the To: and I will be set! here is the code:

    Dim rng
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .To = "ron@debruin.nl"
    .CC = ""
    .BCC = ""
    .Display
    End With
    On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing

  3. #3
    agent- is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    45
    Solved:

    Dim strSql
    Dim db As Database
    Set db = CurrentDb()
    Dim rs As Recordset
    Dim Lrs As DAO.Recordset
    Dim Outlook

    strSql = "SELECT primaryemail FROM tblGoldMine WHERE pipeline=-1;"
    Set Lrs = db.OpenRecordset(strSql)

    Do While Not Lrs.EOF
    Outlook = Outlook + Lrs("primaryemail") + ";"
    Lrs.MoveNext
    Loop


    Dim rng
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .To = Outlook
    .CC = ""
    .BCC = ""
    .Display
    End With
    On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 05-20-2011, 01:56 PM
  2. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM
  3. Passing Email Address Into Outlook
    By cg1465 in forum Access
    Replies: 1
    Last Post: 10-01-2010, 07:59 AM
  4. Exporting Outlook email addresses
    By noidea in forum Import/Export Data
    Replies: 0
    Last Post: 08-01-2009, 01:48 PM
  5. Combining two Email Addresses
    By Frodo in forum Access
    Replies: 0
    Last Post: 09-16-2007, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums