![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
I am new to outlook add-in programming and am having a variety of problems.
Today it's existing attachments. I am trapping the Send event and trying to process attachments on the message item. In this case a message with attachments is being forwarded. I find that: 1) if I change the message body property, the attachments are deleted. If I change the bodyhtml property, the attachments remain. 2) if I add a new attachment, the existing attachments are deleted. I expected the existing attachments to be retained when I add a new one and did not expect changing the body property to affect the attachments. Any help or pointers to documentation discussing these issues would be appreciated! |
#2
|
|||
|
|||
![]()
Probably the attachments are embedded in the item and by changing Body you
are overwriting the original attachment references in the original html. If you are preserving the original html when you change HTMLBody that would explain that. Show the code where you add a new attachment. -- 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 ... I am new to outlook add-in programming and am having a variety of problems. Today it's existing attachments. I am trapping the Send event and trying to process attachments on the message item. In this case a message with attachments is being forwarded. I find that: 1) if I change the message body property, the attachments are deleted. If I change the bodyhtml property, the attachments remain. 2) if I add a new attachment, the existing attachments are deleted. I expected the existing attachments to be retained when I add a new one and did not expect changing the body property to affect the attachments. Any help or pointers to documentation discussing these issues would be appreciated! |
#3
|
|||
|
|||
![]()
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. "Ken Slovak - [MVP - Outlook]" wrote: Probably the attachments are embedded in the item and by changing Body you are overwriting the original attachment references in the original html. If you are preserving the original html when you change HTMLBody that would explain that. Show the code where you add a new attachment. -- 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 ... I am new to outlook add-in programming and am having a variety of problems. Today it's existing attachments. I am trapping the Send event and trying to process attachments on the message item. In this case a message with attachments is being forwarded. I find that: 1) if I change the message body property, the attachments are deleted. If I change the bodyhtml property, the attachments remain. 2) if I add a new attachment, the existing attachments are deleted. I expected the existing attachments to be retained when I add a new one and did not expect changing the body property to affect the attachments. Any help or pointers to documentation discussing these issues would be appreciated! |
#4
|
|||
|
|||
![]()
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. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
saving all attachments where the some of the attachments have thesame name | nosliwmada | Outlook - General Queries | 0 | December 6th 07 03:48 PM |
attachments? | McDermotts | Outlook Express | 1 | July 26th 07 03:49 AM |
attachments | Hank McCarrick | Outlook - General Queries | 3 | January 6th 07 02:19 AM |
OE attachments | stcev | Outlook Express | 2 | December 30th 06 07:57 PM |
Attachments - or not | mavis | Outlook Express | 2 | October 16th 06 04:21 PM |