Send a RTF file in the body of an email

I currently have a email being generated in access using the SendObject command. I want to include a report in RTF format.

Is there anyway to send the report in the body of an RTF email rather than an attachment?

Sponsored Links:


I am a beginner to VBA. I am using MS access 2003. I found some code that works great for sending automatic emails to a list of recipients. My email addresses are housed in a table on access and they are pulled into a query to send an email to only those who are listed in my query.

Right now the code uses a text document as the body of the email. Is there a way to change the code in order to use a word document instead of a text document? I also want it to transfer the text and pics from the word document over to the body of email exactly how it looks. For example if the text is bold or colored, thats how I want it to look in the body of the email. However i did find code that will use a word document as the body of an email on word, I would like to do that but using VBA on access 2003.

The second thing is that I will be sending an email to a massive list of recipients. I was able to use the code to add all the email addresses to a single email on the TO: recipient from my list of email addresses from my query. Can the code be altered to show all the email addresses as Undisclosed Recipents when the email is sent? The main thing is that I want to ensure the recipients can't see the massive email list of other reciepents. Also if they click the reply to all by accident, I want them to only be able to send a reply back to just the sender.

I would really appreciate all the help. Thank you for taking the time

Here is the code I am using:

Public Function SendEMail()

Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String

Set fso = New FileSystemObject
Subjectline$ = InputBox$("Please enter the subject line for this mailing.", _
"We Need A Subject Line!")

If Subjectline$ = "" Then
MsgBox "No subject line, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "E-Mail Merger"
Exit Function
End If
BodyFile$ = InputBox$("Please enter the filename of the body of the message.", _
"We Need A Body!")
If BodyFile$ = "" Then
MsgBox "No body, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "I Ain??t Got No-Body!"
Exit Function
End If

If fso.FileExists(BodyFile$) = False Then
MsgBox "The body file isn??t where you say it is. " & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "I Ain??t Got No-Body!"
Exit Function
End If
Set MyBody = fso.OpenTextFile(BodyFile, ForReading, False, TristateUseDefault)
MyBodyText = MyBody.ReadAll

Set MyOutlook = New Outlook.Application

Set db = CurrentDb()

Set MailList = db.OpenRecordset("MyEmailAddresses")

Set MyMail = MyOutlook.CreateItem(olMailItem)

Do Until MailList.EOF

MyMail.Recipients.Add = MailList("email")



MyMail.Subject = Subjectline$

MyMail.body = "Dear Recipient(s)" & "," & vbNewLine & vbNewLine & MyBodyText


Set MyMail = Nothing
Set MyOutlook = Nothing
Set MailList = Nothing
Set db = Nothing

End Function

I am trying to create an outlook email using MS Access 2003. In the body of the email I am trying to print values from a a table or query. For example if I have a table that has 3 rows of data such as:

Field1 Field2 Field3
abc abc abc
ab2 ab2 ab2
123 123 123

I want to print the rows in the body of the text just as they appear above. I can create the email, but when I try to display the values, I can only get the first row to be displayed. I tried creating a querydef, opening the querydef as a recordset to get the values, then seting the values to a variable and using a do until eof statement. can soneone help?

Example of my code is listed below. Specifically I am trying to have the "ReserveTNinfo" variable display the rows from the "rs1" recordset which is set to the qdf1 querydef. I tried using a do until loop to change the values set to the "ReserveTNinfo" vairable to display each row in the querydef

Dim CustOrder, TTUEvent, BodyText1, BodyText2, QuestionsText, OMTeleconference, ReserveTNtext, ReserveTNinfo
Dim TTULocation, PreTestLocation
Dim SendCalendarInviteMsg, SendCalendarInviteStyle, SendCalendarInviteTitle, SendCalendarInviteResponse
Dim objOutlook As Outlook.Application
Dim outMail As Outlook.AppointmentItem
Dim db As Database
Set db = CurrentDb
Dim rs1 As Recordset
Dim qdf1 As QueryDef
Dim BVOIPval As String
Dim strTNQuery As String
Dim strSQLtn As String
strTNQuery = "qryTempTNinfo" & Me.Parent![OM_UID]
If fExistQuery(strTNQuery) Then
'DoCmd.DeleteObject acQuery, strTNQuery
End If
BVOIPval = Forms![frmordermanager]![BVOIP].Value
strSQL = "SELECT [TN Info].TN_From, [TN Info].TN_To, ([TN_To]-Right([TN_From],4))+1 AS TotalTNs FROM [TN Info]WHERE ((([TN Info].BVOIP)='" & BVOIPval & "') AND (([TN Info].[TN Type])='N'));"
Set qdf1 = db.CreateQueryDef(strTNQuery, strSQLtn)
Set rs1 = qdf1.OpenRecordset
SendCalendarInviteMsg = "Do you want to create an email calendar invite for this TTU event?" ' Define message.
SendCalendarInviteStyle = vbYesNo + vbDefaultButton1 ' Define buttons.
SendCalendarInviteTitle = "Send a Calendar Invite?" ' Define title.
SendCalendarInviteResponse = MsgBox(SendCalendarInviteMsg, SendCalendarInviteStyle, SendCalendarInviteTitle) 'Displays dialog box asking user if they want to send a calendar invite
If SendCalendarInviteResponse = vbYes Then ' User choses to send a calendar invite.
ReserveTNtext = vbCrLf & vbCrLf & "Your BVOIP voice services will be activated using the following new telephone numbers (TNs):" & vbCrLf & vbCrLf & " Reserved TNs" & vbCrLf & " FROM" & " TO " & " Total " & vbCrLf

ReserveTNinfo1 = rs1![TN_From] & " to " & rs1![TN_To] & " " & rs1![TotalTNs]
BodyText1 = "The " & Format(TTUEvent, "

I tried to search for my problem, but somehow I could not locate exactly what I needed.

I am generating a report using sendobject in html format, this saves the file in the specified location.

What i then want to do is to use this file in the body of an e-mail.
I am not very conversant with how to play with html files.

Would be grateful if somebody could help

Hello Access Expert

My supervisor would like me to post the contents of a report in the body of an email instead of attaching it as a .txt file. Is this possible to do in Access via VBA? I know that the DoCmd.SendObject has an argument for the body but it can only be a string.

Thanks very much for your help and responses.

I have spent 2 hours reading the posts with no solution to this. I am sending SMS messages via email to an SMS server and need to insert data into the body of an email as text. The data is in a temp table but could come direct from the query.

Note it must be text in the body otherwise it will not be seen by the person recieving the sms message

I have a recordset automating the email send. My current working code is:

Private Sub CMDTextResults_Click()
'On Error GoTo Err_CMDTextResults_Click

Dim db As DAO.Database
Dim rs As DAO.Recordset

Dim rsEmail As DAO.Recordset
Dim strEmail As String
Set rsEmail = CurrentDb.OpenRecordset("QRYTextPremierResultsRece ipantList")
Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("TexTaddress").Value
DoCmd.SendObject , , , strEmail, , , "Results Central Soccer", "data from temp table to go here"
Set rsEmail = Nothing
Set db = Nothing

' MsgBox Err.Description
' Resume Exit_CMDTextResults_Click

End Sub

How can I get the table data into the Body??

Thanks all replies

I have a user form for supplier issues and a button that captures the data into the body of an email. I'd like to be able to format the message in the email with returns and such to make it more readable.

The user enters the problem then clicks the update button which has a simple send no object email behind it.

My thought was to us ascii Carriage Return which according to the lookup table is Dec:13 Hx: D Oct:015 Char:CR. I don't know how to go about putting this in the body of the email message code.

I'd like not to have to create a report to send as an attachment but don't want them to receive a random string of info bits or a run together paragraph to decipher.

Help would be appreciated, other suggestions welcome.

Thank you in advance.

Does anyone know if this can be done? I have a table named "exported_data" that I need to send (tab delimited and including field names) in the body on an e-mail. The code I have so far is:

Dim db2 As Database
Set db2 = CurrentDb
Dim datatoemail As Recordset
Set datatoemail = db2.OpenRecordset("exported_data")
DoCmd.SendObject acSendNoObject, , , "", , , "Subject", datatoemail, True
'Delete all records from exported_data (temporary data)
CurrentDb.Execute "Delete * From exported_data"

I'm getting an error that says that the data type isn't correct...I'm guessing because datatoemail is a recordset. I know that there's probably a few more steps involved but I'm stuck. Can anyone offer any guidance? Thank you!

I'm having a terrible importing the body of an Outlook message into Microsoft Access.

Anyone know of an easy way to do this, or has some code that can do this for me.


I wanted to know if it is possible to embed a pivot table (from a query) in the body of an email. I know how to use VBA to embed data from a table in the body, but not sure how to incorporate an entire pivot table, or if it can be done.


I have a database I've created to send out tailored reports to recipients on email. This was done using a module (which creates the outlook session etc and has all the handling info etc on it) and a form with a command button + click event with the mailbody/subject,attachment path etc on it.

Everything works fine like this and currently reports are sent in the form of an attachments to the tailor made email for each recipient. What we want to do now though is instead of having each report on an attachment, we'd like the report detail to be included in the body of the email. The purpose of the attachments is for them to be completed and sent back which isn't happening.. so if recipients could just reply to the original email (with the detail on) its much easier for all concerned. I'm sure this is possible but I'm stuck on how to achieve it.

The attachment is based on a query - which is refreshed for each email according to the recipient (and data) so I was hoping to be able to reference in code to the SQL query in the on click event. I'm assuming I need to assign it to a string maybe as a recordset and do a loop so I get all the records from the query on my email. Its the coding for it that I'm struggling with and where to put it amongst the other code already written.

Any help would be great.. I've attached a file showing what i've got - hope this helps?


I am looking for a way to send an access HTML report in the body of an email instead of an attachment. Is there an easy way to do this ?

Sending them as attachment is very straight forward but I was unable to find any information on how to send it in the body of a mail

It appears that many people have the same issue but no solution

Thank you


I have a very simple report that I need to have in the body of an email. I have a form with a button that should activate outlook, add the simple report to the body of the email and send. The TO: field will be blank due to a distro list. The subject field should also have a standard constant message.

The report is updated in access so it doesn't need to be done in this code. I need this to be very simple. I am having code-writing-block. Please assist with this.

I would also like to have the format be txt not html or snapshot.

thank you all for the assistance.

here is my code

Dim strMsgBody As String
strmsgbody = ??????

DoCmd.OpenReport "Daily_Text", acViewPreview, "", "", acNormal
DoCmd.SendObject acReport, "Daily_Text", "SnapshotFormat(*.snp)", "", "", "", "LNP Totals", strMsgBody, True, ""
MsgBox "Text Message report has been processed.", vbInformation, ""

I have the following code to save e-mails from outlook to a text file, however, I want to save the body of the e-mail only. The problem is when .msg converts to .txt, the saved text file has a bunch of wingdings & corrupted data. I'm hoping that saving the body of the message only will solve this problem. Thank you in advance for your help.

Dim myOlapp As Outlook.Application
Dim myNameSpace As Outlook.Namespace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Set myOlapp = CreateObject("Outlook.Application")
Set myNameSpace = myOlapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.Folders("Mailbox - Inbox").Folders("Inbox")

For Each myItem In myFolder.Items
If InStr(myItem.Subject, "E-mail Subject") And myItem.SentOn > Date Then
myItem.SaveAs "Y:Email.txt"
myItem.UnRead = False
End If

I use cdo to create e-mails.
How can I include a graphic file in the message of an html e-mail?
Like a company logo
I use Access 2000

I need a solution that is e-mail client independant. It must use cdo only

I need to know if it is possible to create a TextBox in the body of an email. Currently I am using HTML for the body of my email.

I have an email that I send out for Audit Findings. I would like some large text boxes in the email so they could fill out their responses and forward back the email to me. I could then copy and paste the the information in the textboxes where I need to.

I have 2 issues with a report that I am trying to send in the body of an email to different recipients:
First, I need to export the report to the body of an outlook email message. The report is very simple text with no tableslines or anything like that, so there is no real need for HTML formatting.
Second, I would like the "To:" field in outlook to be populated from an "email" field on a form that is open when the "send email" button is clicked. In other words, I want Access to pass the contents of a field to the "To:" line in outlook, somehow.
I am a new Access user with practically NO coding experience: please be gentle.

Thanks for any help.

I know this had been addressed before but a.) all the previous posts were specific to a particular problem or the problem was far more comlpex than what I want to do and b.) I'm not very good with VBA, so if it possible to piece together how to to a simple report in the body of an email from the code in previous posts, I was unable to do it.

All I want to do is put a text report into the body of an email. There is no formatting neccessary. The only cavaet, which prevents me from hard-coding text into the body, is the text needs to contain fields. What I haev is this:

A data input form.
A query that pulls some of the fields from the record for the current form.
A report that has some text, with fields from the query inserted, like a form letter. ie. Dear [Employee_Name],
A button on the form to run the email code.

Currently I used a SendOjbect macro to output the report as an rtf attachment and uses one of the fields for the To:, which works fine, but ideally I'd like the text in the body. I was able to code enough (based on the afforementioned posts) to open Outlook, create an email, set the To: to the employee name based on the form, and set the subject line. I just can't figure out the report-in-the-body bit.

Any help is greatly appreciated!

Does anyone know what's the best way to send a mdb file via the internet. I've tried sending is as an email attachment and putting is on a webserver for downloading. Both wayes only gives errors.

I need to write a query to add a “0” in the middle of a sting of numbers

Ex. Error…… 07121260210

Should be…..071212060210

I figured out how to add on to the beginning and end, but not in the middle.

Any help would be greatly appreciated.

thank you