Thread: Attachments
View Single Post
  #4  
Old May 20th 08, 02:24 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Attachments

The only real way to tell what's going on is to capture the existing HTML
code in HTMLBody before you start your changes and after to see what's going
on. Usually if the attachments are embedded images the HTML for them would
start like this:

img style="border: 0px" src=

Then the reference for the image would be either a URL or a cid reference. A
cid reference would indicate an attached image file.

The Position argument is really only effective in RTF messages.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Richard" wrote in message
...
Ken,
Thanks for taking this up. In my code, I was setting the bodyhtml and the
body properties to some boiler plate text. Setting the bodyhtml did not
disturb the existing attachments, setting the body made the attachments
drop
out of the attachments collection. Im this case, the existing attachments
are
images referenced in the body html and if the references are removed, then
I
guess it makes sense to remove the images. The images are shown as by
value
type, position 0 (hidden). But you would think replacing the bodyhtml
would
cause a problem as well. The goal is put the body into it's own attachment
and replace the body with boiler plate. Then when received, the process
will
be reversed. Here is a snippet of code:

HtmlHeader = "!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN""HTMLHEADMETA http-equiv=Content-Type
content=""text/html;charset=Diso-8859-1""META content=""MSHTML
6.00.6000.16608"" name=GENERATORSTYLE/STYLE/HEADBODY
bgColor=#ffffffDIVFONT face=Arial size=2"""
HtmlHeader = HtmlHeader.TrimEnd("""")
HtmlTrailer = "/FONT/DIV/BODY/HTML"

Select Case MailItem.BodyFormat
Case Outlook.OlEditorType.olEditorText
'AddinExpress.OE.BodyFormats.FormatPlain
My.Computer.FileSystem.WriteAllText(FileName,
MailItem.Body, False)
MailItem.Body = MessageReplacement

Case Outlook.OlEditorType.olEditorHTML
'AddinExpress.OE.BodyFormats.FormatHTML
My.Computer.FileSystem.WriteAllText(FileName,
MailItem.HTMLBody, False)
MailItem.HTMLBody = HtmlHeader +
MessageReplacement.Replace(vbCrLf, "br") + HtmlTrailer
'MailItem.Body = MessageReplacement

I checked the attachments collection before and after the last two
statements above to see that the attachments were being affected by
chaning
the body parameter.


Ads