Results 1 to 2 of 2
  1. #1
    Steven.Allman is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2010
    Posts
    118

    Using EMAIL option

    So I have been using Access to create emails for some time.
    I have two or three contacts for each "State", but I am wanting to now create REGIONS and email those regions.
    So currently my SendNoObject works perfect, with a good script for looking at EMAIL_1 and if not blank ";" & EMAIL_2, etc works great..
    but... how can I code something to look at
    contacts!Email_1 for all records where ME!Region = Contacts!region


    I don't even know if I am headed the right direction with this code.....
    but it would, in theory, compose my email to everyone in Indiana, Illinois, Michigan, Iowa, Wisconsin, Ohio......

    The following is my current code for emailing a single state.
    _________________________________
    Private Sub Command38_Click()
    Dim rstBook1 As DAO.Recordset
    Dim strTo As String
    Set rstBook1 = CurrentDb().OpenRecordset("SELECT * FROM book1 WHERE [BAC]='" & Me!BAC & "'", dbOpenDynaset)
    strTo = ""
    If Not IsNull(rstBook1("ncoEmail1")) Then
    strTo = strTo + rstBook1("NCOEmail1")
    End If
    If Not IsNull(rstBook1("NCOEmail2")) Then
    strTo = strTo & ";" & rstBook1("NCOEmail2")
    End If

    If Not IsNull(rstBook1("NCOemail3")) Then
    strTo = strTo & ";" & rstBook1("NCOemail3")
    End If
    DoCmd.SendObject acSendNoObject, , , strTo, STRCC, , "Message from SAP", "Good Day...", , 0
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Sounds like you can open a recordset using the region criteria. Presuming that can return multiple records, you'd loop the recordset and build a string of your recipients. Here's my loop template code:

    Code:
      Dim strSQL  As String
      Dim db      As DAO.Database
      Dim rs      As DAO.Recordset
    
      Set db = CurrentDb()
      
      strSQL = "SELECT ..."
      Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
    
      Do While Not rs.EOF
        'build your string here
        rs.MoveNext
      Loop
    
      rs.Close
      set rs = nothing
      set db = nothing
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 10-03-2014, 06:36 AM
  2. Email Data Collection, Update existing info not an option.
    By johnb11 in forum Import/Export Data
    Replies: 1
    Last Post: 08-08-2013, 01:29 AM
  3. Combo Box Wizard does not have option form option
    By CementCarver in forum Forms
    Replies: 5
    Last Post: 02-28-2013, 08:54 PM
  4. no option to import xls file or option all files
    By captgnvr in forum Import/Export Data
    Replies: 3
    Last Post: 09-22-2009, 10:19 AM
  5. VB code for sending email through Option Group?
    By getdpt in forum Programming
    Replies: 0
    Last Post: 08-23-2009, 03:59 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