Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    52

    Unanswered: Sending Emails using addresses listed on Access

    I'm adding the finishing touches on my contacts database. I've seemed to run into a problem. I can't figure out how to extract email addresses from my search form results and import them into outlook. I believe that this involves some sort of loop function.

    Can anyone help?

  2. #2
    Join Date
    Mar 2004
    Location
    Ohio
    Posts
    16
    Not sure what your trying to add email addresses to Outlook, or use Outlook to email users from your recordset. I have used the following code to email multiple users.


    Public Sub SendMessage()
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
    Dim i As Integer, j As Integer
    Dim dbs As Database, rst As Recordset
    Dim strSQL As String, buff As String


    ' Create the Outlook session and empty message
    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    strSQL = "SELECT EmailAddress FROM source;"
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset(strSQL)
    If rst.RecordCount > 0 Then
    rst.MoveLast
    rst.MoveFirst
    With objOutlookMsg
    For j = 1 To rst.RecordCount
    Set objOutlookRecip = .Recipients.Add(rst!EmailAddress)
    rst.MoveNext
    Next j
    objOutlookRecip.Type = olTo
    .Subject = "Subject line"
    .Body = "Whatever you want to say"
    .Importance = olImportanceNormal 'Normal importance
    .Send
    End With
    End If
    Set rst = Nothing
    Set dbs = Nothing
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    End Sub

  3. #3
    Join Date
    Mar 2004
    Posts
    52

    JKassil

    Thanks! By the way, my goal is to extract the email adresses from my contacts form into outlook.

  4. #4
    Join Date
    Mar 2004
    Posts
    52
    I noticed that your SQL statement point towards a table, would it be anydifferent if you were using a form, as a result of a search, to extract the email addresses?

  5. #5
    Join Date
    Mar 2004
    Location
    Ohio
    Posts
    16
    The search results would represent a recordset, so no I don't believe it would matter.

    I am trying to do something similar from Exchange to SQL, so not sure if I would be able to help with populating Outlook directly from Access.
    I do know that for my application, I need to use Microsoft DB OLE Provider for Exchange to link directly to the contacts in Exchange.

    I also know that a link to Outlook can be setup in Access, but it uses the local machines profile. This wasn't a good solution for me in a multi-user environment.

    For whatever that's worth...

Posting Permissions

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