Add Query or Table data to email body

LB79

Registered User.
Local time
Today, 22:32
Joined
Oct 26, 2007
Messages
505
Hi All,
I have a function that creates and email in Outlook but I want to add a ‘Top 10’ list to the email body.
The data will come from a query.

This is my ‘create email’ function but I have no idea how to add the query result to the body.
If any one can help that’d be great.

Thanks
Code:
[/FONT][/COLOR]
[SIZE=3][COLOR=#000080][FONT=Arial]UserNME = "MyName" [/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set FSO = New FileSystemObject[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Subjectline = “My Subject"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]MyBodyText = "Dear My email body”[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set MyOutlook = New Outlook.Application[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set DB = CurrentDb()[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set MyMail = MyOutlook.CreateItem(olMailItem)[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]MyMail.To = "Email@Address"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]MyMail.Subject = Subjectline[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]MyMail.Body = MyBodyText[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]MyMail.Display[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set MyMail = Nothing[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set MyOutlook = Nothing[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set MailList = Nothing[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]DB.Close[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set DB = Nothing[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]DoCmd.Hourglass False[/FONT][/COLOR][/SIZE]
[COLOR=black][FONT=Verdana]
 
You would open a recordset on the query and loop through it. Within the loop:

MyBodyText = MyBodyText & rs!FieldName & vbCrLf

Which would list them on individual lines. You can of course format them out any way you want.
 

Users who are viewing this thread

Back
Top Bottom