Results 1 to 4 of 4
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    Trying To Insert Query/Recordset Results Into Body Of Outlook Email

    Greetings..

    I think Google got me close and I'm hoping I can find my way home with your guys' help...



    What I'm trying to do seems simple enough - As the User inputs data into a form a TmpTbl populates with EmpNames & EmpID's.

    Upon clicking the 'Submit' button I would like all of the names and ID's from that table to be inserted into the body of an Outlook email.

    The code below works insofar as it produces a result without error - but it only inserts just the 'last' EmpName from the table into the email body - No EmpID.

    Code:
    Dim Dbs As DAO.Database
    Dim Rs As DAO.Recordset
    Dim StrSQL As String
    Set Dbs = CurrentDb
              
       StrSQL = "SELECT * FROM QryTmpTktEmail"
       Set Rs = Dbs.OpenRecordset(StrSQL, dbOpenSnapshot)
           
          Do While Not Rs.EOF
             Boo = Rs("EmpName") & vbNewLine
             Rs.MoveNext
          Loop
            
            strBodyPass = "Hello," & vbCrLf & vbCrLf & _
                          "Please Submit Tickets For The Following Associates." & vbCrLf & vbCrLf & _
                           Boo
    Also, I just need the names and ID's - nothing fancy, no need for HTML formatting or the table grids, etc.

    Thanks as always for any help...

  2. #2
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    Update...

    I figured out how to get both the name & ID with the following:
    Code:
    Do While Not Rs.EOF
       Boo = Rs("EmpName") & " " & _
       Rs("EmpID") & vbNewLine
       Rs.MoveNext
    Loop
    The above, of course, still inserts only the last record (EmpName & EmpID) from the table

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Boo = Boo & vbNewLine & Rs("EmpName") & " " & Rs("EmpID")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    June ~

    Thank You, So Very Much!!

    RT...

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

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2018, 10:38 AM
  2. Adding query results to email body
    By Kaye960 in forum Programming
    Replies: 2
    Last Post: 12-14-2015, 10:57 PM
  3. sending data into an email body - outlook
    By webisti in forum Access
    Replies: 6
    Last Post: 02-15-2012, 07:05 AM
  4. FORMATTING Outlook Email in BODY of Access code
    By taimysho0 in forum Programming
    Replies: 7
    Last Post: 11-28-2011, 11:04 AM
  5. Query displayed as body of email - edit
    By virnier in forum Access
    Replies: 0
    Last Post: 03-16-2011, 01:26 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