email query results in table in body of email

james_halliwell

Registered User.
Local time
Today, 18:30
Joined
Feb 13, 2009
Messages
211
Hi, need some help, i have created some code to get the records of a query and it puts them in the body of the emaiil but it doesnt format it well for examlpe the email looks like

James | halliwell | 31
Leanne | smith |27
Alexis | smith |8


i would like it to be in a table is this possible,


Code:
Public Function SendEmail()
Dim MyDB As DAO.Database
Dim rst As DAO.Recordset
  
Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset("QryUKBackOrderSummary", dbOpenForwardOnly)
  
With rst
  Do While Not .EOF
    Mailbody = Mailbody & ![ProductType] & " | " & ![ProductCode] & " | " & ![Description] & vbCrLf
      .MoveNext
  Loop
End With
  

Dim appOutLook As Outlook.Application
   Dim MailOutLook As Outlook.MailItem
   Dim strPath As String
   Dim strFileName As String
   Set appOutLook = CreateObject("Outlook.Application")
   Set MailOutLook = appOutLook.CreateItem(olMailItem)
   
   
   
   With MailOutLook
     .BodyFormat = olFormatRichText
     .To = "[EMAIL="JHalliwe@myemail.com"]JHalliwe@myemail.com[/EMAIL]"
     '.CC = ""
     '.bcc = ""
     .Subject = "BackOrder Report" & Date
     .Body = "UK Backorder Report " & vbCrLf & " " & vbCrLf & Mailbody
            
     .Send
End With
rst.Close
Set rst = Nothing
  
  MsgBox "done"

any help would be greatly appreciated
 
Hi James

I recommend you do a table in html.

Format your email as html. Then your MailBody string can be then html you would write to do a table.

It helps if you write and test your html first before trying to work out how to build the string.

hth
Chris
 
First thanks for taking the time to help me out, do you have an example format of HTML so I can start to play around

Many thanks
 
Find it on the web - you can online create a table to yuour liking and then obtain the corresponding html
 

Users who are viewing this thread

Back
Top Bottom