A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook HTML.Body



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 21st 07, 04:18 PM posted to microsoft.public.outlook.program_vba
grahamproctor
external usenet poster
 
Posts: 1
Default Outlook HTML.Body


In VBA (Office 2003), I am trying to create a new email and set the body
text to a saved HTML document but my graphic is not being displayed. I
have used the following combinations of code (each try is commented
out) but without success. If I use .mht and open the email in the
Outbox the graphic appears but when I save and reopen it, it appears as
a placeholder only, not the graphic.

I would appreciate any ideas. Thanks, Graham.

Dim fso As FileSystemObject
Dim ts As TextStream
Dim strText As String

Set fso = CreateObject("Scripting.FileSystemObject")

'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\RepplyF.htm", ForReading)
Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.htm", ForReading)
'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.mht", ForReading)
'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.mht.doc", ForReading)
'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.htm.doc", ForReading)

strText = ts.ReadAll

mai1.HTMLBody = strText


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in

Ads
  #2  
Old January 21st 07, 11:23 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook HTML.Body

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

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"grahamproctor" wrote in message
...

In VBA (Office 2003), I am trying to create a new email and set the body
text to a saved HTML document but my graphic is not being displayed. I
have used the following combinations of code (each try is commented
out) but without success. If I use .mht and open the email in the
Outbox the graphic appears but when I save and reopen it, it appears as
a placeholder only, not the graphic.

I would appreciate any ideas. Thanks, Graham.

Dim fso As FileSystemObject
Dim ts As TextStream
Dim strText As String

Set fso = CreateObject("Scripting.FileSystemObject")

'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\RepplyF.htm", ForReading)
Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.htm", ForReading)
'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.mht", ForReading)
'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.mht.doc", ForReading)
'Set ts = fso.OpenTextFile("g:\Medics Away\Mailing
Documents\Repply.htm.doc", ForReading)

strText = ts.ReadAll

mai1.HTMLBody = strText


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in



  #3  
Old January 23rd 07, 09:20 PM posted to microsoft.public.outlook.program_vba
grahamproctor
external usenet poster
 
Posts: 1
Default Outlook HTML.Body


Many, many thanks Dmitri and all the great advice you make available.

I have only one problem now:

how do I get the HTML text into the Body following the graphic?

Am I thick or is this stuff DIFFICULT ????

Graham


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in

  #4  
Old January 24th 07, 12:54 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook HTML.Body

I am not sure I understand - what do you mean by "Body following the
graphic"? You do not split the HTML body into multiple part (before and
after), you set the whole thing.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"grahamproctor" wrote in message
...

Many, many thanks Dmitri and all the great advice you make available.

I have only one problem now:

how do I get the HTML text into the Body following the graphic?

Am I thick or is this stuff DIFFICULT ????

Graham


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in



  #5  
Old January 24th 07, 10:53 AM posted to microsoft.public.outlook.program_vba
grahamproctor
external usenet poster
 
Posts: 1
Default Outlook HTML.Body


Thanks again, Dmitri.

What I am trying to achieve is having a graphic at the top of the email
body, immediately followed by text which has been customised with
different fields from a database, dependent on the recipient and other
parameters.

The uncustomised text is currently stored in a .htm and I have
successfully customised this HTML in code, before putting it into the
HTML.Body. So conceptually, I am trying to append that HTML text to the
graphic already in the body of the email.

I tried before to have the graphic in the .htm but that was
unsuccessful because the graphic just turned into a placeholder when it
reached Outlook. Funnily enough, the graphic did appear in the untitled
email when it was displayed from code but when I sent or saved it, the
graphic disappeared when it was in the Outbox.

I tried your other trick to make the graphic a watermark/background in
the body and that worked fine, except for sizing issues but that still
left me with the problem of how to append the HTML text to the
HTML.Body without replacing the graphic which was already successfully
placed there.

I suppose I could try to combine the graphic and text into a .jpg in
code and then use your trick but how I would do that I have no idea.

Puzzling? Not for you!!!

All the best, Graham.


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in

  #6  
Old January 24th 07, 04:58 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook HTML.Body

So you really need to merge two HTML strings into one. You can either create
an instance of the IHTMLDocument2 object, load your data, then modify the
HTML (insert other HTML strings, etc) using DOM.
Or, if you simply need to insert an HTML substring at the very beginning
1. Find the position of the "body" substring
2. Find the position of the next "" character (this is needed to skip over
the body attributes)
3. Insert new HTML at that position + 1.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"grahamproctor" wrote in message
...

Thanks again, Dmitri.

What I am trying to achieve is having a graphic at the top of the email
body, immediately followed by text which has been customised with
different fields from a database, dependent on the recipient and other
parameters.

The uncustomised text is currently stored in a .htm and I have
successfully customised this HTML in code, before putting it into the
HTML.Body. So conceptually, I am trying to append that HTML text to the
graphic already in the body of the email.

I tried before to have the graphic in the .htm but that was
unsuccessful because the graphic just turned into a placeholder when it
reached Outlook. Funnily enough, the graphic did appear in the untitled
email when it was displayed from code but when I sent or saved it, the
graphic disappeared when it was in the Outbox.

I tried your other trick to make the graphic a watermark/background in
the body and that worked fine, except for sizing issues but that still
left me with the problem of how to append the HTML text to the
HTML.Body without replacing the graphic which was already successfully
placed there.

I suppose I could try to combine the graphic and text into a .jpg in
code and then use your trick but how I would do that I have no idea.

Puzzling? Not for you!!!

All the best, Graham.


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in



  #7  
Old January 25th 07, 01:13 PM posted to microsoft.public.outlook.program_vba
grahamproctor
external usenet poster
 
Posts: 1
Default Outlook HTML.Body


Hi Dmitry

The problem is I don't have 2 HTML strings, I have a graphic (.jpg)
which your excellent advice has fooled Outlook into putting into the
HTMLBody but I still have the problem of how to get the customised text
(HTML string) appended to that image. Whatever I do seems to replace the
contents of the HTMLBody and lose the graphic.

I have received many HTML emails which have a graphic (which is
actually a link to another site) followed by text and that would be
good.

At the moment I am completely stumped - using IHTMLDocument2 object and
DOM is technically beyond me at the moment without an example (I am
using VBA and the code in is Access).

Yours desperately,

Graham.


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in

  #8  
Old January 25th 07, 05:51 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook HTML.Body

I still don't understand: why can't you have both image and extra text in
HTML body?

html
body
Text before image
p
img src="cid:MyTestCID"
p
Text after image
/body
/html

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"grahamproctor" wrote in message
...

Hi Dmitry

The problem is I don't have 2 HTML strings, I have a graphic (.jpg)
which your excellent advice has fooled Outlook into putting into the
HTMLBody but I still have the problem of how to get the customised text
(HTML string) appended to that image. Whatever I do seems to replace the
contents of the HTMLBody and lose the graphic.

I have received many HTML emails which have a graphic (which is
actually a link to another site) followed by text and that would be
good.

At the moment I am completely stumped - using IHTMLDocument2 object and
DOM is technically beyond me at the moment without an example (I am
using VBA and the code in is Access).

Yours desperately,

Graham.


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in



  #9  
Old January 25th 07, 06:25 PM posted to microsoft.public.outlook.program_vba
grahamproctor
external usenet poster
 
Posts: 1
Default Outlook HTML.Body


Hi again, Dmitri.

I think it is because the PC on which Outlook is being used to send the
message holds the image on its disk and when the email is sent that
image is not contained in the email message except by a reference. That
reference cannot be located by the email when the recipient gets it,
hence the graphic appears as a placeholder.

I suppose if I put an image on the web server, I could reference it
with a href ... /a.

I suppose I could also create a link to somewhere if I could show the
link as the elusive graphic but I don't know how to do that.

Your method of changing the graphic attachment to be the HTMLBody
solves that problem because the graphic is sent with the email and does
not reference back to the Outlook sender PC.

However, with your method, having cunningly converted the graphic
attachment to the HTMLBody, I cannot append the message to the body,
only overwrite it.

Does that make any sense?

Respectfully, Graham.


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in

  #10  
Old January 25th 07, 08:30 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook HTML.Body

I still do not understand what the problem is: sample code at
http://www.outlookcode.com/d/code/htmlimg.htm does *not* "converted the
graphic
attachment to the HTMLBody", it simply makes sure that the image in HTMLBody
refers to an attachment instead of an external location.
Maybe you can give an example of what you need to do and show what you set
the HTMLBody to and what you want it to be.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"grahamproctor" wrote in message
...

Hi again, Dmitri.

I think it is because the PC on which Outlook is being used to send the
message holds the image on its disk and when the email is sent that
image is not contained in the email message except by a reference. That
reference cannot be located by the email when the recipient gets it,
hence the graphic appears as a placeholder.

I suppose if I put an image on the web server, I could reference it
with a href ... /a.

I suppose I could also create a link to somewhere if I could show the
link as the elusive graphic but I don't know how to do that.

Your method of changing the graphic attachment to be the HTMLBody
solves that problem because the graphic is sent with the email and does
not reference back to the Outlook sender PC.

However, with your method, having cunningly converted the graphic
attachment to the HTMLBody, I cannot append the message to the body,
only overwrite it.

Does that make any sense?

Respectfully, Graham.


--
grahamproctor
------------------------------------------------------------------------
grahamproctor's Profile: http://www.officehelp.in/member.php?userid=6171
View this thread: http://www.officehelp.in/showthread.php?t=1325714

Posted from - http://www.officehelp.in



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML olAppointment Body? Tony Gravagno Add-ins for Outlook 5 December 19th 06 09:53 PM
HTML in Task Body K Passaur Outlook and VBA 2 August 21st 06 05:22 AM
mailto - html in body Giorgio Outlook Express 7 June 21st 06 02:41 PM
Graphics in HTML Body GeorgeMar Outlook and VBA 2 February 27th 06 02:17 PM
sending html in body of outlook xp email Help a Novice Please Outlook - General Queries 3 February 22nd 06 06:50 AM


All times are GMT +1. The time now is 12:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.