Link to home
Start Free TrialLog in
Avatar of perrybond
perrybond

asked on

With SendObject, how do you send html formated email ?

In MSaccess I create an email using:
DoCmd.SendObject acReport, stDocName, acFormatHTML, Cust_email, , , MyTitle , MyWaffle

Where Mywaffle is a long text string that forms the message of the email.

This is plain text using vbcrlf and vbtab to lay out the message.

I now want to create the message in html to get it to look better; how do I do that?

How do you imbed the html document into the email message?

I have created a template file, but not sure how to get the data (using visual basic) to the variable
ie how do a populate <!--AcessTemplate_Body-->      with data?

Or do you just put the html tags in the string (mywaffle), if so what setting in outlook do you need to change to get it to work?
ASKER CERTIFIED SOLUTION
Avatar of xSinbad
xSinbad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of perrybond
perrybond

ASKER

Sorry, I did not want to add an attachment, I want to send an email where the body of the email is using html.
I receive emails html formatted so I know it is possible.
"Where Mywaffle is a long text string that forms the message of the email."

All you need to do is build a string that contains the html-formatted text and pass it as MyWaffle.

Are you familiar with html tags?

Wes
Yes, I have no problem with the html tags.
I have written the hrml in a txt file, checked it was OK, cut and pasted it into some VBA behind MSaccess, used this as the string 'MyWaffle', edited it to include the variables to display the live data, then used sendobject.

However, as Outlook opened, the text string was displayed as is, not html formatted.

I now assume from your reply that I am doing it right in the VBA and the problem occours with the settings within outlook.

I will look into this and report back

Thanks
This is really turning into an Outlook question, not MSaccess

In Outlook I've changed the mail settings in the options to rich text (html) and if a write a new email, it is html formatted.

When I use sendObject, the new email pops up as plain text.

Should I go and ask this question under Outlook?

Perry
This is really turning into an Outlook question, not MSaccess

In Outlook I've changed the mail settings in the options to rich text (html) and if a write a new email, it is html formatted.

When I use sendObject, the new email pops up as plain text.

Should I go and ask this question under Outlook?

Perry
Rather than struggle with Docmd.Sendobject, you could use xSinbad's code to automate Outlook.  This gives you much greater control anyway.

Instead of working with the .body property, however, you will work with the .htmlbody property.  This should produce the output you're looking for.  It will look something like this:

.Subject = "This is an Automation test with Microsoft Outlook"
.HTMLBody = "This should be <b>bold</b>."
.Importance = olImportanceHigh  'High importance

This way you don't need to send an attachment.

Wes
             
     

Thanks, this sounds a good idea, only I cannot get xsinbads code to work

I cannot even get the dims to compile.

i have some MAPI stuff that is working and creating emails; I don't really understand how it works, but cannot find any way of using html with it.

If someone could help me getting xsindads code working i would be most gratefull.

we are using MSaccess98 and Outlook98

From any module in design view, click >>Tools>>References.  You'll need to find a reference for Outlook 98 Type Library.  Activate this reference and all your Outlook object declarations will compile.

Wes

Great, cracked it !!!
Thanks xsinbad for the code and thanks wes for the help.
I know I can split points, but I don't know how !
Thanks for the code, it just took me a while to figure out it WAS what I wanted