Results 1 to 5 of 5
  1. #1
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368

    Email from Access

    Hey guys,

    I have a code wich i know has the records in my filter :

    Code:
    Dim rst As Object
    Set rst = Me.RecordsetClone
    On Error Resume Next
    rst.MoveLast
    On Error GoTo 0
    Now i found a piece of code that selects emailadressen from my table.

    Code:
    Dim rst As DAO.Recordset
    Dim strTo As String
    Set rst = CurrentDb.OpenRecordset("SELECT [EmailAddress] FROM Members
    WHERE [EmailAddress] Is Not Null")
    With rst
    Do Until .EOF
    strTo = strTo & ![EmailAddress] & ";"
    .MoveNext
    Loop
    .Close
    End With
    strTo = Left(strTo, Len(strTo)-1)
    Set rst = Nothing
    


    My question is how to combine the two codes, or is there a better way to pull emailadresses from my table that are IN my recordset ?
    So i have a form and im filtering records. I want to email the people in my recordset.

    Im using this to email :



    Code:
    
    
    Code:
    DoCmd.SendObject , , , strTo, , , , , True
    Any help would be appreciated !

    Greetings, Jeroen

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Code:
    Dim rst
    Dim strTo As String
    
    Set rst = CurrentDb.OpenRecordset("SELECT [EmailAddress] FROM Members WHERE [EmailAddress] Is Not Null")
    With rst
        While Not .EOF
             strTo = strTo & .Fields("EmailAddress").Value & ";"
           .MoveNext
        Wend
       .Close
    End With
    strTo = Left(strTo, Len(strTo) - 1)
    Set rst = Nothing
    
    DoCmd.SendObject acSendReport, "rptMyReport", acFormatPDF, strTo, , , "subject", "body"
    if you use a form, put the sql in a list box, so you have a list of the emails, and a list of reports,
    then the user can pick any report to print, and send it to everyone in the list.

  3. #3
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Hi Ranman,

    Im not sending reports (yet anyway).
    I just want the "to" filled with emailadresses that meet my criteria.

    So the emailadresses must be in my current recordset and they must not be empty.
    Some objects dont have emailadresses.

    When i adjust your code to my situation i still get every record in my table rather then the filtered ones from the recordset.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    then the query needs to limit the list to valid emails,
    and the OUTPUT can be excel, or pdf or text.

  5. #5
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Well outputting it to a text file before i actually send them is not a bad idea for starters as i just allmost send some 200 mails accidently
    But the idea is to eventually put the emailadresses directly into the emails.
    Still i get the complete set of records and i can't seem to combine my recordset with the SQL that pulls the emailadresses from the table.

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

Similar Threads

  1. Replies: 1
    Last Post: 12-22-2014, 09:21 PM
  2. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  3. Replies: 1
    Last Post: 05-01-2014, 11:37 AM
  4. Replies: 22
    Last Post: 04-24-2014, 01:56 PM
  5. Replies: 3
    Last Post: 03-25-2013, 11:01 PM

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