Outlook 2007 mangling HTMLBody changes, Not supporting image maps?

  • Thread starter Thread starter bitstream
  • Start date Start date
B

bitstream

So, I have an application which hooks the MailItem Send event in
Outlook and wraps the message in a template automagically. The product
is basically a way to wrap your emails in a template that appears like
your company letterhead, but with the nice features of HTML added to it
such as linking to specific bits of information on the customers
website. When they send the message to their customers, they have one
nice email with important links and contact information wrapped around
the message body.

In Outlook 2000, XP and 2003 this works flawlessly. In Outlook 2007,
not so much.

The product inserts links to images and wraps them in a server side
image map (ISMAP). This accomplishes two things for the product. The
image maps allow us to link to specific portions of the customers
website rather than one location. Also, by linking to the images when
the customer updates there templates with new images or changed
information after the cached images expire in Outlook, the emails get
the changed images/new information.

Generally speaking the images contain user specific information, such
as the users name, phone numbers, title, address, ect. The image maps
for these business card type images contain a default link to the vcard
for the user, as well as special links for maps to the users location,
or in many cases biographies or references specific to the user sending
the message.

All of this is done via remote linking rather than embedding images to
keep the message small and facilitate the dynamic republishing aspect.

Well, in Outlook 2007, when I insert the HTML into the message by
setting HTMLBody, the image link is replaced with an image attachment.
The image is resized/recreated, its not even the original image.
Images which were originally linked as GIFs become JPEGs or PNGs of
32x32 pixels in size.

Also in the process, the image map attribute of the image link is
removed making any click on the image go to the default link which is
wrapped around the image.

In my debugging I've found that the images can be prevented from
shrinking by adding the proper width/height attributes to the img
reference. The images are still recreated as a different file type and
attached to the message rather than being left as a link, but atleast
they look right.

Also during this process no matter what HTML I place in HTMLBody,
Outlook replaces it with Wordy html. Sending an html message with only
the word 'test' in a 20KB message body for the HTML section alone. I
know this isn't a lot in the grand scheme of things, and disk space is
cheap, but thats not the point.

Can anyone provide me with some way to prevent Outlook from mangling
what I set the HTMLBody to?

I've created an example app to make sure I'm not doing anything else
silly that would cause this to occur, so either MS has decided no one
else knows how to make HTML that will work in email clients, or I'm not
setting something.

I've tried setting the HTMLBody to w3c validated HTML, I've tried
wrapping the HTML in the same fluff that Outlook puts in when you
compose a message thinking maybe it wanted to see some specific styles
or tags, neither of this things made a difference.

The following code is what I use in my example COM Addon to test the
problem. I've tried it in the ItemSend event, as well as both the Save
and Write events of MailItem, all produce the same results, atleast its
consistent. The following is my MailItem send event handler

Private Sub objMailItem_Send(Cancel As Boolean)
objMailItem.HTMLBody = "<a
href=""http://mm1.lettermark.net/rtsz/lhead/news_rtsz.map""
name=""f7hmap""><img width=""600"" height=""78""
src=""http://mm1.lettermark.net/rtsz/lhead/news_rtsz.gif""
name=""f7img"" ISMAP></a><br/>Header Image"
End Sub

The Addon is created using VB6 due to the legacy nature of the existing
code base I must maintain.

On a side note, it appears that even though Microsoft claims the img
tag supports ISMAP, when I view messages sent from other email clients
which send without modifing my message, it always goes to the default
link completely ignoring the ISMAP in Outlook2007. Has anyone seen
Outlook 2007 work with ISMAPs? Or for that matter client side maps?

And for the recorded, I'd be perfectly happy if someone told me that
our image maps are screwed up or the HTML is missing something mind
numbingly obvious that other clients just happen to work around as long
as I can make it work in Outlook 2007.

David
 
Outlook 2007 does not support background images. Before you go on
playing with your code, read about the massively changed HTML/CSS
capabilities in 2007: http://pschmid.net/blog/2006/10/05/56

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
 
Yea, but that html isn't a background image or any CSS. Its just an
image, with an image map, and some text. You can't get much simpler.

The MS documentation (
http://msdn2.microsoft.com/en-us/library/aa338201.aspx ) claims to
support img elements with ismap attributes.

Also the real problem is that its mangling the message when sending it.
If it didn't mangle it when sending atleast the messages would work
for anyone with any other email client. If you view the message source
in the Sent Items, or in another client it those few HTML entities turn
into 20kb of word-ish stylesheets and xml.

I need to find out if there is any possible way to make Outlook leave
the message body as I set it, rather than reparsing it and mangling it.
Outlook 2007 does not support background images. Before you go on
playing with your code, read about the massively changed HTML/CSS
capabilities in 2007: http://pschmid.net/blog/2006/10/05/56

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

So, I have an application which hooks the MailItem Send event in
Outlook and wraps the message in a template automagically. The product
is basically a way to wrap your emails in a template that appears like
your company letterhead, but with the nice features of HTML added to it
such as linking to specific bits of information on the customers
website. When they send the message to their customers, they have one
nice email with important links and contact information wrapped around
the message body.

In Outlook 2000, XP and 2003 this works flawlessly. In Outlook 2007,
not so much.

The product inserts links to images and wraps them in a server side
image map (ISMAP). This accomplishes two things for the product. The
image maps allow us to link to specific portions of the customers
website rather than one location. Also, by linking to the images when
the customer updates there templates with new images or changed
information after the cached images expire in Outlook, the emails get
the changed images/new information.

Generally speaking the images contain user specific information, such
as the users name, phone numbers, title, address, ect. The image maps
for these business card type images contain a default link to the vcard
for the user, as well as special links for maps to the users location,
or in many cases biographies or references specific to the user sending
the message.

All of this is done via remote linking rather than embedding images to
keep the message small and facilitate the dynamic republishing aspect.

Well, in Outlook 2007, when I insert the HTML into the message by
setting HTMLBody, the image link is replaced with an image attachment.
The image is resized/recreated, its not even the original image.
Images which were originally linked as GIFs become JPEGs or PNGs of
32x32 pixels in size.

Also in the process, the image map attribute of the image link is
removed making any click on the image go to the default link which is
wrapped around the image.

In my debugging I've found that the images can be prevented from
shrinking by adding the proper width/height attributes to the img
reference. The images are still recreated as a different file type and
attached to the message rather than being left as a link, but atleast
they look right.

Also during this process no matter what HTML I place in HTMLBody,
Outlook replaces it with Wordy html. Sending an html message with only
the word 'test' in a 20KB message body for the HTML section alone. I
know this isn't a lot in the grand scheme of things, and disk space is
cheap, but thats not the point.

Can anyone provide me with some way to prevent Outlook from mangling
what I set the HTMLBody to?

I've created an example app to make sure I'm not doing anything else
silly that would cause this to occur, so either MS has decided no one
else knows how to make HTML that will work in email clients, or I'm not
setting something.

I've tried setting the HTMLBody to w3c validated HTML, I've tried
wrapping the HTML in the same fluff that Outlook puts in when you
compose a message thinking maybe it wanted to see some specific styles
or tags, neither of this things made a difference.

The following code is what I use in my example COM Addon to test the
problem. I've tried it in the ItemSend event, as well as both the Save
and Write events of MailItem, all produce the same results, atleast its
consistent. The following is my MailItem send event handler

Private Sub objMailItem_Send(Cancel As Boolean)
objMailItem.HTMLBody = "<a
href=""http://mm1.lettermark.net/rtsz/lhead/news_rtsz.map""
name=""f7hmap""><img width=""600"" height=""78""
src=""http://mm1.lettermark.net/rtsz/lhead/news_rtsz.gif""
name=""f7img"" ISMAP></a><br/>Header Image"
End Sub

The Addon is created using VB6 due to the legacy nature of the existing
code base I must maintain.

On a side note, it appears that even though Microsoft claims the img
tag supports ISMAP, when I view messages sent from other email clients
which send without modifing my message, it always goes to the default
link completely ignoring the ISMAP in Outlook2007. Has anyone seen
Outlook 2007 work with ISMAPs? Or for that matter client side maps?

And for the recorded, I'd be perfectly happy if someone told me that
our image maps are screwed up or the HTML is missing something mind
numbingly obvious that other clients just happen to work around as long
as I can make it work in Outlook 2007.

David
 
Have you tried going beneath OOM, using Redemption.MAPIUtility.HrSetOneProp
(or equivalent extended MAPI call)? Maybe that would bypass Outlook's
foolishness and write it straight to the store?

Whether it would work depends on when/where Outlook imposes it's view of
'correctness' on your content -- if it applies changes at the transport
layer, you're screwed; if it fixes it up when it renders, you're equally
screwed (though only on Outlook 2007 email clients.)

Just a shot in the dark, hope it helps.


-Mark


Yea, but that html isn't a background image or any CSS. Its just an
image, with an image map, and some text. You can't get much simpler.

The MS documentation (
http://msdn2.microsoft.com/en-us/library/aa338201.aspx ) claims to
support img elements with ismap attributes.

Also the real problem is that its mangling the message when sending it.
If it didn't mangle it when sending atleast the messages would work
for anyone with any other email client. If you view the message source
in the Sent Items, or in another client it those few HTML entities turn
into 20kb of word-ish stylesheets and xml.

I need to find out if there is any possible way to make Outlook leave
the message body as I set it, rather than reparsing it and mangling it.
Outlook 2007 does not support background images. Before you go on
playing with your code, read about the massively changed HTML/CSS
capabilities in 2007: http://pschmid.net/blog/2006/10/05/56

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

So, I have an application which hooks the MailItem Send event in
Outlook and wraps the message in a template automagically. The product
is basically a way to wrap your emails in a template that appears like
your company letterhead, but with the nice features of HTML added to it
such as linking to specific bits of information on the customers
website. When they send the message to their customers, they have one
nice email with important links and contact information wrapped around
the message body.

In Outlook 2000, XP and 2003 this works flawlessly. In Outlook 2007,
not so much.

The product inserts links to images and wraps them in a server side
image map (ISMAP). This accomplishes two things for the product. The
image maps allow us to link to specific portions of the customers
website rather than one location. Also, by linking to the images when
the customer updates there templates with new images or changed
information after the cached images expire in Outlook, the emails get
the changed images/new information.

Generally speaking the images contain user specific information, such
as the users name, phone numbers, title, address, ect. The image maps
for these business card type images contain a default link to the vcard
for the user, as well as special links for maps to the users location,
or in many cases biographies or references specific to the user sending
the message.

All of this is done via remote linking rather than embedding images to
keep the message small and facilitate the dynamic republishing aspect.

Well, in Outlook 2007, when I insert the HTML into the message by
setting HTMLBody, the image link is replaced with an image attachment.
The image is resized/recreated, its not even the original image.
Images which were originally linked as GIFs become JPEGs or PNGs of
32x32 pixels in size.

Also in the process, the image map attribute of the image link is
removed making any click on the image go to the default link which is
wrapped around the image.

In my debugging I've found that the images can be prevented from
shrinking by adding the proper width/height attributes to the img
reference. The images are still recreated as a different file type and
attached to the message rather than being left as a link, but atleast
they look right.

Also during this process no matter what HTML I place in HTMLBody,
Outlook replaces it with Wordy html. Sending an html message with only
the word 'test' in a 20KB message body for the HTML section alone. I
know this isn't a lot in the grand scheme of things, and disk space is
cheap, but thats not the point.

Can anyone provide me with some way to prevent Outlook from mangling
what I set the HTMLBody to?

I've created an example app to make sure I'm not doing anything else
silly that would cause this to occur, so either MS has decided no one
else knows how to make HTML that will work in email clients, or I'm not
setting something.

I've tried setting the HTMLBody to w3c validated HTML, I've tried
wrapping the HTML in the same fluff that Outlook puts in when you
compose a message thinking maybe it wanted to see some specific styles
or tags, neither of this things made a difference.

The following code is what I use in my example COM Addon to test the
problem. I've tried it in the ItemSend event, as well as both the Save
and Write events of MailItem, all produce the same results, atleast its
consistent. The following is my MailItem send event handler

Private Sub objMailItem_Send(Cancel As Boolean)
objMailItem.HTMLBody = "<a
href=""http://mm1.lettermark.net/rtsz/lhead/news_rtsz.map""
name=""f7hmap""><img width=""600"" height=""78""
src=""http://mm1.lettermark.net/rtsz/lhead/news_rtsz.gif""
name=""f7img"" ISMAP></a><br/>Header Image"
End Sub

The Addon is created using VB6 due to the legacy nature of the existing
code base I must maintain.

On a side note, it appears that even though Microsoft claims the img
tag supports ISMAP, when I view messages sent from other email clients
which send without modifing my message, it always goes to the default
link completely ignoring the ISMAP in Outlook2007. Has anyone seen
Outlook 2007 work with ISMAPs? Or for that matter client side maps?

And for the recorded, I'd be perfectly happy if someone told me that
our image maps are screwed up or the HTML is missing something mind
numbingly obvious that other clients just happen to work around as long
as I can make it work in Outlook 2007.

David
 
When the Send event is fired Outlook will change the HTML unfortunately.
It's part of the repagination process that goes on when send is called and
the item is sent to the mail transport.

That happened even in WordMail 2003 but the limitations on HTML were looser
in that version so it wasn't usually noticed. Take a look at nicely crafter
HTML hand inserted into HTMLBody at the sender level and the received level
to see how much ugly Word HTML stuff is put in the message.
 
Ken-

Thanks for your input.

I went back and looked at the way it worked in Outlook2k3 and see the
same thing happening there like you said. Between this change in
Outlook 2k7 and bad design on our part, we're going to have to redesign
a fairly large portion of our system to deal with the changes to 2k7.

I don't know if I should thank Microsoft for creating job security for
me, or stab some people in the eye with a plastic spork for making
development a nightmare. I just wish you could atleast make image maps
work!

Either way, thank you for your insight.

David
 
I know the feeling and sympathize. Other than the fact that Outlook 2007 is
a full-employment act for Outlook developers, it annoys me to have to
re-write lots of addins that were working perfectly previously.
 
Back
Top