Outlook Email Message Body

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
752
I have a command button on a form , that gets a report and puts it in the body of an email message. There is no problem with this, but the problem is that the report in the message part of the email comes out weird. The data gets cut off, and it seems like there is a paragraph mark on every 2nd row. Any suggestions? Thanks

Network: Any Network

Shipping .E. Engineer
Shipping Jimmy Welch

Shipping Street 280 S. Elm Street
Shipping rady

Shipping A
Shipping Zip 90018

Shipping Phone: 10-123-4872
Shipping 310-123-4872

FedEx Shipment Type: Ground
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
No one has replied, just in case, here is the code...

Private Sub Command67_Click()
Dim olApp As Outlook.Application, olMailitem As Outlook.MailItem
Dim FSTextStream As Scripting.TextStream, FSObj As Scripting.FileSystemObject
Dim strHTMLFile As String

'Name of the temporary data file used to store the
'report in HTML format - change as desired
strHTMLFile = "C:\temp\rpt.txt"

'Output the report in HTML format
DoCmd.OutputTo acOutputReport, "rpt fibersat", acFormatTXT, strHTMLFile

'Open the text file that we've just created
Set FSObj = CreateObject("Scripting.FilesystemObject")
Set FSTextStream = FSObj.OpenTextFile(strHTMLFile, ForReading)

'Create an Outlook message and set its HTMLBody property to what we created above
Set olApp = New Outlook.Application
Set olMailitem = olApp.CreateItem(0)

With olMailitem
.Body = FSTextStream.ReadAll

'You can set all sorts of properties of your email e.g.
.Subject =
.To =
.Importance = olImportanceHigh

'Use .Send to send the email automatically, or .Display to show it
olMailitem.Display

End With

'Clear up
Set FSTextStream = Nothing: Set FSObj = Nothing

End Sub
 
Upvote 0
We'll I solved my problem and in case you are interested how I did it.

We'll it took some minor formatting of the fields in the report and change the following line

DoCmd.OutputTo acOutputReport, "rpt fibersat", acFormatTXT, strHTMLFile

I changed acFormatTXT to acFormatRTF.

Parra (y)
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,716
Members
451,665
Latest member
PierreF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top