Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    59

    Unanswered: Help with Sendmail

    Hey all,
    I'm pretty new to Access and trying to sort out a sendmail button. I've created a function that sends to a specified e-mail address but am having troubles sending it to the e-mail addresses listed on my query. I have provided the code I currently have below. In the section below I just want to know what I could include in the line strEmailAddress so that it would call e-mail addresses from the query.

    Code:
    Public Sub SendMail()
    'Provides the Send Mail automation
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSubject As String
    Dim strEmailAddress As String
    Dim strEMailMsg As String
    Dim ingCounter As Integer
    Dim intCount As Integer
    
    strSubject = "Latest Job Outcomes"
    strEmailAddress = "[need help here!]"
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("qryEmailOut")
    
    
    rst.MoveFirst
    Do Until rst.EOF
        
        strEMailMsg = rst![First Name] & " " & rst![Surname] _
        & " - "
    
        'EMAIL USER DETAILS & ATT REPORT
        DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
        , , strSubject, strEMailMsg, False, False
        
    
        rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing
    dbs.Close
    Set dbs = Nothing
        
    End Sub
    Thanks
    Russ

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    The same way you are using the first name and surname from the recordset...
    Code:
    Do Until rst.EOF
    
        strEmailAddress = rst![email address]
    
        'send mail
    
        rst.MovNext
    Loop
    George
    Home | Blog

Posting Permissions

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