How do I insert the results of an Access query into email w/ grid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thank you in advance,

I need to send the results of an Access query into an Outlook email body
with grids. I was able to parse the results of the query using the followin
-------------------------------------------------------------------------------------------
Set MyQuery = dt.OpenRecordset("qry_SALES_MAIL_OREGON MED WA", dbOpenDynaset)
Do While Not MyQuery.EOF
myResult = myResult & Trim(Left(MyQuery.Fields("Customer_Name").Value,
20)) & _
Space(20) & Format(MyQuery.Fields("Pending").Value, "currency") & _
Space(20) & Format(MyQuery.Fields("IN Process").Value, "currency") & _
Space(20) & Format(MyQuery.Fields("Posted").Value, "Currency") & _
Space(20) & Format(MyQuery.Fields("Total Sales Opportunity").Value,
"Currency") & vbNewLine
MyQuery.MoveNext
Loo
-------------------------------------------------------------------------------------------
Is there a way to have this information displayed with grids like of a table
grid?
I have set the email (.BodyFormat = olFormatHTML) in Access

Thank you
 
Randal:

One alternative is to use an HTML table. For example:

Dim ol As New Outlook.Application
Dim itm As Outlook.MailItem
Dim rs As DAO.Recordset
Dim sHTML As String

Set itm = ol.CreateItem(olMailItem)

Set rs = CurrentDb.OpenRecordset("SELECT * FROM Stats")

sHTML = "<HTML><Body><table border='1'
width='50%'><tr><th>ID</th><th>Value</th><th>Mean</th><th>SD</th></tr>"

Do Until rs.EOF
sHTML = sHTML & "<tr><td>" & rs("ID") & "</td><td>" & rs("Value") &
"</td><td>" & rs("Mean") & _
"</td><td>" & rs("SD") & "</td></tr>"
rs.MoveNext
Loop

sHTML = sHTML & "</table></body></html>"

itm.HTMLBody = sHTML

You can use standard HTML formatting attributes and tags to customize the
table to your tastes.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Thank you in advance,

I need to send the results of an Access query into an Outlook email body
with grids. I was able to parse the results of the query using the following
-------------------------------------------------------------------------------------------
Set MyQuery = dt.OpenRecordset("qry_SALES_MAIL_OREGON MED WA",
dbOpenDynaset)
Do While Not MyQuery.EOF
myResult = myResult & Trim(Left(MyQuery.Fields("Customer_Name").Value,
20)) & _
Space(20) & Format(MyQuery.Fields("Pending").Value, "currency") & _
Space(20) & Format(MyQuery.Fields("IN Process").Value, "currency") & _
Space(20) & Format(MyQuery.Fields("Posted").Value, "Currency") & _
Space(20) & Format(MyQuery.Fields("Total Sales Opportunity").Value,
"Currency") & vbNewLine
MyQuery.MoveNext
Loop
-------------------------------------------------------------------------------------------
Is there a way to have this information displayed with grids like of a table
grid?
I have set the email (.BodyFormat = olFormatHTML) in Access

Thank you
 
Back
Top