Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email reports in message body using Access

Status
Not open for further replies.

cybercop23

IS-IT--Management
Aug 12, 2001
103
US
Hi all. Hopefully I got the right forum for this question.

I have an Access report that I need to email it as part of the email message. It can't be an attachement. I could do it as an attachement, however some receipients are pager or cell phones and they can't read attachements. It needs to be the report format, since the remaining receipients are using an email client and I need to preserve the formating.
Any ideas?

 
So you basically want to send the info from the report as plain text in the message body. You can't do it with the report itself, but if you take the report recordsource (table or query), get everything from it, build the message body and use SendObject to send it. Here is a code sample that sends a recordset as a tab delimited text (the info is formatted).

Code:
Sub SendReportAsBody()
Dim mybody As String
Dim myrs As DAO.Recordset
Dim fld As Field
Set myrs = CurrentDb.OpenRecordset("YourReportRecordSource")

'header
For Each fld In myrs.Fields
mybody = mybody & fld.Name & Chr(vbKeyTab)
Next

With myrs
Do Until .EOF
mybody = mybody & vbCrLf
    For Each fld In myrs.Fields
    mybody = mybody & fld & Chr(vbKeyTab)
    Next
.MoveNext
Loop
.Close
End With
Set myrs = Nothing
DoCmd.SendObject , , , "To addresses", "CC addresses", "BCC Adresses", "Subj:", mybody, True
End Sub

Hope this helps,

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top