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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send Mail in html format with SendObject? 1

Status
Not open for further replies.

jetspin

Programmer
Mar 5, 2002
76
Hi.

I can send mail using the SendObject Method, but I cannot send mail in an html format. Can someone tell me what I'm missing? Thanks. Here is my code.

Dim strToWhom As String
Dim strMsgBody As String
Dim strMsgSubject As String

strToWhom = "vern@mydomain.com"
strMsgSubject = "Confirmation"
strMsgBody = &quot;<HTML><HEAD><TITLE></TITLE></HEAD><BODY><FONT face=Arial size=2><STRONG>&quot; & vbCrLf
strMsgBody = strMsgBody & &quot;Thank You for using our service!<BR><BR>&quot; & vbCrLf
strMsgBody = strMsgBody & &quot;Vern<BR>80 Main St<BR>Somewhere, TXC 11111<BR>V. 111.111.2222<BR>F.333.4444.4444&quot; & vbCrLf
strMsgBody = strMsgBody & &quot;</STRONG></FONT></BODY></HTML>&quot; & vbCrLf

DoCmd.SendObject , acSendNoObject, acFormatHTML, strToWhom, , , strMsgSubject, strMsgBody, True
 
Hi jetspin,

It's actually much simpler than that. Just build a macro tied to a command button.
1. Use the SendObject Action.
2. Specify the object type as report and the name as your created report
3. Specify Output Format as HTML
4. Specify default mailing header lines (if you want) such as addressee, sender, subject, etc. You can even put canned text in the email if you're sending the same thing over and over...
5. At Edit message, select &quot;Yes&quot; if you want to alter the email before you send it.

That's it. After hitting the button, Outlook will open with your new email, addressed to whoever you specify (I always send it to my office group) and with your report attached as an html document, which opens from OE.

Hope that helps!
Patrick

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Have you thought about sending the report as a snapshot. I do this using the below:

Dim strSubject as String

strSubject = Me.MyFormFieldName

DoCmd.SendObject acSendReport, &quot;reportname&quot;, acFormatSNP, &quot;To addressee here&quot;, &quot;CC addressee here&quot;,, &quot;Subject here&quot;, &quot;Message here&quot;

Maybe that can help,

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Hi.

I still do not understand. I do not have a report to send.
I simply want to send the text body as a variable in the sendobject command line. I can do this as text, but I want to do it as HTML... If I have to do it as a report, then how do I write a report,,, what is its file name...etc..
Do I design a 1 page report that accepts an rec id number which I know how to do, but how do I do I run, print to a file, save it all in script?

It just so easy to do it all in one command line already as ascii text and there is a acFormatHTML....but this must only be for reports?

Any info would be appreciated. I've searched the web with mixed results about doing everything but something so simple.... just to run the sendobject command with a variable that containts the text in html format. Is that possible?

The only reason I want to use html is because I need to imbed a hyperlink. Its to send a customer a FedEx link of a tracking number. In ascii text, it gets truncated.

I will work on your suggestions in the mean time. Thanks!

 
Yes you would build a report, which you say you already know how to do. The rec ID field is the field to use to print a specific report.

Try this, and if you have questions, let me know.

Thanks,

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top