View Single Post
  #4  
Old October 27th 06, 04:57 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook 2003 Script: HTML Mail

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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"news.microsoft.com" wrote in message ...

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 = "HTMLbiH1This is the Header of my
mail/H1/i/bbrbrhrp align=""center"" img
src=""\\MyComputer\myfolder\Images\MyImage.bmp""
/PhrbrbrbrpH2 style=""color:red""This some infomation about
the content/H2bra
/a/p brPscript
type=text/vbscriptdocument.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 & "HTMLMMMMMMMMMMMMMMMMMMM/HTML"

myitem.Display

myitem.HTMLBody = StrHTML + StrBB

End Sub


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....


Ads