Outlook 2003 Script: HTML Mail

N

news.microsoft.com

Hi all,

I made a custom task wich generate and send an e-mail (HTML), I used
HTML.body

I have 3 pb

1) How to add variable (some text) to the HTML body ? when I add something
all the content of the Html is replaced by the text I added and the body
switch to Text format....

2) I added an image (logo) to the HTML mail but when the mail is received
the place of the image is empty

3) I want to use different color in my Html mail but I fail to use more
than one color , it always take the last color I used

Tks fo help
 
S

Sue Mosher [MVP-Outlook]

1) Show a code snippet to illustrate the problem. Remember that the content of HTMLBody must be fully tagged, consistent HTML code, just like in a web page.

2) See http://www.outlookcode.com/d/code/htmlimg.htm

3) Use <font> tags, just as you would in a web page.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

news.microsoft.com

Hi Sue,

3) solved it'was easy tks sue
2) I'll take a look

1)here a part of the code
sub SendAlertButton_click()

' THIS IS THE CONTENT OF THE BODY OF MY

' TASK THAT I WANT TO ADD TO THE CONTENT OF HTML MALI

StrBB = item.body

Set myItem = Application.CreateItem(0)

StrHTML = "<HTML><b><i><H1>This is the Header of my
mail</H1></i></b><br><br><hr><p align=""center"" ><img
src=""\\MyComputer\myfolder\Images\MyImage.bmp"" >
</P><hr><br><br><br><p><H2 style=""color:red"">This some infomation about
the content</H2><br><a
href=""mailto:[email protected]"">[email protected]</a></p> <br><P><script
type=text/vbscript>document.write(item.body)</script></P></HTML>"

'HERE ARE THE DIFFERENT THINGS I TRYED

StrHTML = StrHTML & "<p>" & strDetails & "</p>"

myitem.HTMLBody = StrHTML

'myitem.Body = StrHTML + StrBB

myitem.htmlBody = myitem.htmlbody & "<HTML>MMMMMMMMMMMMMMMMMMM</HTML>"

myitem.Display

myitem.HTMLBody = StrHTML + StrBB

End Sub

=================================================================



"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de %23X5A3Nd%[email protected]...
1) Show a code snippet to illustrate the problem. Remember that the content
of HTMLBody must be fully tagged, consistent HTML code, just like in a web
page.

2) See http://www.outlookcode.com/d/code/htmlimg.htm

3) Use <font> tags, just as you would in a web page.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

None of your efforts will work because none of them produce valid HTML. In other words, you missed the basic principle I expressed in my earlier message, "... the content HTMLBody must be fully tagged, consistent HTML code, just like in a web
page." You can see this problem if, for example, after these statements execute:

myitem.HTMLBody = StrHTML
StrHTML = StrHTML & "<p>" & strDetails & "</p>"

you look at the value of strHTML. Is it valid HTML? No, because it has a <p> tag after the closing </html> tag.

All of your other attempts suffer from the same problem (or worse, they try to insert script, which won't run in HTML messages). Instead of appending text to the existing HTML, you need to ***insert text inside*** the existing HTML content. There are two ways to do that with straightforward text parsing (no need to use the HTML Document itself). These techniques have nothing specific to do with Outlook or HTML, but are the same techniques you could use to turn "this text" into "this <insert variable text> text":

1) Parse the existing HTML into two sections -- the part before you want to insert your text and the part after -- then concatenate the three: <part before> & <your HTML> & <part after>

2) If you want to append, use the Replace() function to replace the ending </body></html> tags with your text followed by </body></html>.

I find #2 to be by far the easier.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

bbnimda

Ok Sue I understand my mistakes I follow your instruction and now it work
fine

Now I have to undestand your example on how to insert my image

Last thing How can I use the the HTML Format on a task body ??



"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de OQqIVjd%[email protected]...
None of your efforts will work because none of them produce valid HTML. In
other words, you missed the basic principle I expressed in my earlier
message, "... the content HTMLBody must be fully tagged, consistent HTML
code, just like in a web
page." You can see this problem if, for example, after these statements
execute:

myitem.HTMLBody = StrHTML
StrHTML = StrHTML & "<p>" & strDetails & "</p>"

you look at the value of strHTML. Is it valid HTML? No, because it has a <p>
tag after the closing </html> tag.

All of your other attempts suffer from the same problem (or worse, they try
to insert script, which won't run in HTML messages). Instead of appending
text to the existing HTML, you need to ***insert text inside*** the existing
HTML content. There are two ways to do that with straightforward text
parsing (no need to use the HTML Document itself). These techniques have
nothing specific to do with Outlook or HTML, but are the same techniques you
could use to turn "this text" into "this <insert variable text> text":

1) Parse the existing HTML into two sections -- the part before you want to
insert your text and the part after -- then concatenate the three: <part
before> & <your HTML> & <part after>

2) If you want to append, use the Replace() function to replace the ending
</body></html> tags with your text followed by </body></html>.

I find #2 to be by far the easier.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top