?
Solved

Get row headers in email for data from ACCESS 2003

Posted on 2008-10-29
3
Medium Priority
?
186 Views
Last Modified: 2013-11-25
I am working on getting a email automation out of our database.  The first part of the body is standard text depending on how many days an account has been opened and then below that in the email are the various rows with customer data the manager has to review (they do NOT want an attachment, they want the data in the e-mail itself)  I have managed to get to the point where the body and rows are in the email, but how do I get the column headers for the rows information?  right now,just the data appears, not the column titles.
Private Sub ActualEmail()
Dim strMessage As String, txtMaxBranch As String, strTo As String
Dim strSubject As String
Dim appOutLook As Outlook.Application, MailOutLook As Outlook.MailItem
Dim strAddress As String, rstEmail As DAO.Recordset
txtMaxBranch = DMax("BR_NMR", "tblAMLUploadedToday")
Set db = CurrentDb
Set rst = db.OpenRecordset("qryEmail")
 
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
'strAddress = Me.txtEmailAddress
rst.MoveFirst
            strMessage = Me.txtBody & vbCrLf & vbCrLf
            Set appOutLook = CreateObject("Outlook.Application")
            Set MailOutLook = appOutLook.CreateItem(olMailItem)
            With MailOutLook
                .To = txtMaxBranch
                .Subject = Me.txtSubject
                .Body = strMessage
Debug.Print strMessage
' *****************
Do Until rst.EOF
If strMessage = "" Then
strMessage = rst("BR_NMR") & "," & rst("OFCR_CD") & "," & rst("PLAN_NBR") & "," & rst("DAYS_OPEN_CNT") & "," & rst("APPL_TYP_CD") & "," & rst("ACCT_NBR") & vbCrLf & _
    "," & rst("REL_CD") & "," & rst("NM_LINE_1") & "," & rst("NM_LINE_2") & "," & rst("NM_LINE_3") & "," & rst("TAX_ID_NBR") & "," & rst("CIF_NBR") & vbCrLf & _
    "," & rst("NAME_FLG") & "," & rst("TAX_ID_FLG") & "," & rst("DOB_CIF_FLG") & "," & rst("DOB_ACCT_FLG") & "," & rst("GOVMT_ID_FLG") & "," & rst("ADDR_FLG") & vbCrLf & _
    "," & rst("PO_BOX_FLG") & "," & rst("PHONE_FLG") & "," & rst("OFCF_CD_FLG") & "," & rst("OPEN_DT") & "," & rst("OWNR_CD") & "," & rst("MOTHER_NM_FLG") & vbCrLf & _
    "," & rst("OCCUPATION_FLG") & "," & rst("EMPLR_FLG") & vbCrLf
Else
strMessage = strMessage & rst("BR_NMR") & "," & rst("OFCR_CD") & "," & rst("PLAN_NBR") & "," & rst("DAYS_OPEN_CNT") & "," & rst("APPL_TYP_CD") & "," & rst("ACCT_NBR") & vbCrLf & _
    "," & rst("REL_CD") & "," & rst("NM_LINE_1") & "," & rst("NM_LINE_2") & "," & rst("NM_LINE_3") & "," & rst("TAX_ID_NBR") & "," & rst("CIF_NBR") & vbCrLf & _
    "," & rst("NAME_FLG") & "," & rst("TAX_ID_FLG") & "," & rst("DOB_CIF_FLG") & "," & rst("DOB_ACCT_FLG") & "," & rst("GOVMT_ID_FLG") & "," & rst("ADDR_FLG") & vbCrLf & _
    "," & rst("PO_BOX_FLG") & "," & rst("PHONE_FLG") & "," & rst("OFCF_CD_FLG") & "," & rst("OPEN_DT") & "," & rst("OWNR_CD") & "," & rst("MOTHER_NM_FLG") & vbCrLf & _
    "," & rst("OCCUPATION_FLG") & "," & rst("EMPLR_FLG") & vbCrLf & vbCrLf
End If
Debug.Print strMessage
rst.MoveNext
Loop
 
DoCmd.SendObject , , , strTo, , , strSubject, strMessage, 1  'Move outside the loop
 
'
''***********************
                 .Send
               End With
'skip_email:
'        rst.MoveNext
'    Loop
'    rst.Close
'    Set rst = Nothing
 
End Sub

Open in new window

0
Comment
Question by:ssmith94015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 22833997
You can get the actual name of the field like this:

rst("BR_NMR").Name

0
 

Author Comment

by:ssmith94015
ID: 22834128
would this be the first line in the message part that holds the row data?
0
 

Author Closing Comment

by:ssmith94015
ID: 31511272
I figured out the placement, thank you.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question