![]() |
Trying to hide inline attachments
I am writing some code to archive mail.
whel looping through my selection i check every e-mail to see if it contains any attachments. However the outlook api gives me a number of inline attachments that i don't want to see. I only want to see the attachments that are visible via the paperclip icon in office. Does anybody now of a way of detecting these inline attachments. I tried to look at the attachment.type property, but this is not the way to go. I tried analysing the htmlbody to look for the filename, but this was also no help. TIA Otto |
Trying to hide inline attachments
For embedded attachments, you don't find the file name but something like this in html: img src='cid:xxxxx' -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Tue, 12 Feb 2008 02:47:44 -0800 (PST) schrieb : I am writing some code to archive mail. whel looping through my selection i check every e-mail to see if it contains any attachments. However the outlook api gives me a number of inline attachments that i don't want to see. I only want to see the attachments that are visible via the paperclip icon in office. Does anybody now of a way of detecting these inline attachments. I tried to look at the attachment.type property, but this is not the way to go. I tried analysing the htmlbody to look for the filename, but this was also no help. TIA Otto |
Trying to hide inline attachments
And the cid will be the same as in the PR_ATTACH_CONTENT_ID (0x3712001E or
urn:schemas:mailheader:content-id) property on the attachment object. That will give you what to look for if you you're using Outlook 2007 or Extended MAPI or CDO 1.21 or some other API that allows access to properties not exposed in the Outlook 2003 or earlier object models. -- 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 "Michael Bauer [MVP - Outlook]" wrote in message ... For embedded attachments, you don't find the file name but something like this in html: img src='cid:xxxxx' -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 |
Trying to hide inline attachments
Unfortunatly, my problem can't be solved in managed code (see
following link for a quote) http://forums.microsoft.com/MSDN/Sho...72308&SiteID=1 unfortunatly we had to make some consessions in the features of the application due to the short development time (have to deliver the software tomorrow) If i find a solution in managed code, i will post it here. Thnxs for the pointers however ! |
Trying to hide inline attachments
This worked for me (don't mid the sloppy code.... cleaners are on
their way ;) ): public static bool IsValidAttachment(Outlook.MailItem mailitem, Outlook.Attachment attachment) { bool retval = false; string CID = ""; try { if (attachment.FileName != "") { // this skips the olOLE types MAPI.Session session = new Session(); session.Logon("", "", false, false, Type.Missing, Type.Missing, Type.Missing); MAPI.Message message = (MAPI.Message)session.GetMessage(mailitem.EntryID, ""); MAPI.Attachments atts = (Attachments)message.Attachments; for (int teller = 0; teller mailitem.Attachments.Count; teller++) { MAPI.Attachment att = (MAPI.Attachment)atts.get_Item(teller+1); MAPI.Fields fields = (MAPI.Fields)att.Fields; MAPI.Field field = (MAPI.Field)fields.get_Item(MAPI.CdoPropTags.CdoPR _ATTACH_FILENAME, null); if ((string)field.Value == attachment.FileName) { field = (MAPI.Field)fields.get_Item(0x3712001F, null); CID = (string)field.Value; field = (MAPI.Field)fields.get_Item(0x37140003, null); if (!CID.StartsWith(attachment.FileName) && (int)field.Value !=4) retval = true; } } session.Logoff(); } } catch { } if (attachment.Type == Microsoft.Office.Interop.Outlook.OlAttachmentType. olByValue && CID == "") retval = true; return retval; } |
Detecting Inline Attachments
Exactly what I was looking for and so obscure! Thanks so much for posting this.
The problem with detecting inline attachments seems only to occur when using HTML mail. The RTF setting doesn't seem to create them. krach.ara wrote: This worked for me (don't mid the sloppy code.... 23-Feb-08 This worked for me (don't mid the sloppy code.... cleaners are on their way ;) ): public static bool IsValidAttachment(Outlook.MailItem mailitem, Outlook.Attachment attachment) { bool retval = false; string CID = ""; try { if (attachment.FileName != "") { // this skips the olOLE types MAPI.Session session = new Session(); session.Logon("", "", false, false, Type.Missing, Type.Missing, Type.Missing); MAPI.Message message = (MAPI.Message)session.GetMessage(mailitem.EntryID, ""); MAPI.Attachments atts = (Attachments)message.Attachments; for (int teller = 0; teller mailitem.Attachments.Count; teller++) { MAPI.Attachment att = (MAPI.Attachment)atts.get_Item(teller+1); MAPI.Fields fields = (MAPI.Fields)att.Fields; MAPI.Field field = (MAPI.Field)fields.get_Item(MAPI.CdoPropTags.CdoPR _ATTACH_FILENAME, null); if ((string)field.Value == attachment.FileName) { field = (MAPI.Field)fields.get_Item(0x3712001F, null); CID = (string)field.Value; field = (MAPI.Field)fields.get_Item(0x37140003, null); if (!CID.StartsWith(attachment.FileName) && (int)field.Value !=4) retval = true; } } session.Logoff(); } } catch { } if (attachment.Type == Microsoft.Office.Interop.Outlook.OlAttachmentType. olByValue && CID == "") retval = true; return retval; } Previous Posts In This Thread: On Wednesday, February 13, 2008 1:10 AM Michael Bauer [MVP - Outlook] wrote: For embedded attachments, you don't find the file name but something likethis For embedded attachments, you don't find the file name but something like this in html: img src='cid:xxxxx' -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Tue, 12 Feb 2008 02:47:44 -0800 (PST) schrieb : On Wednesday, February 13, 2008 2:48 AM krach.ara wrote: Trying to hide inline attachments I am writing some code to archive mail. whel looping through my selection i check every e-mail to see if it contains any attachments. However the outlook api gives me a number of inline attachments that i don't want to see. I only want to see the attachments that are visible via the paperclip icon in office. Does anybody now of a way of detecting these inline attachments. I tried to look at the attachment.type property, but this is not the way to go. I tried analysing the htmlbody to look for the filename, but this was also no help. TIA Otto On Wednesday, February 13, 2008 10:01 AM Ken Slovak - [MVP - Outlook] wrote: And the cid will be the same as in the PR_ATTACH_CONTENT_ID (0x3712001E or And the cid will be the same as in the PR_ATTACH_CONTENT_ID (0x3712001E or urn:schemas:mailheader:content-id) property on the attachment object. That will give you what to look for if you you're using Outlook 2007 or Extended MAPI or CDO 1.21 or some other API that allows access to properties not exposed in the Outlook 2003 or earlier object models. -- 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 "Michael Bauer [MVP - Outlook]" wrote in message ... On Friday, February 15, 2008 10:02 PM krach.ara wrote: Unfortunatly, my problem can't be solved in managed code (seefollowing link Unfortunatly, my problem can't be solved in managed code (see following link for a quote) http://forums.microsoft.com/MSDN/Sho...72308&SiteID=1 unfortunatly we had to make some consessions in the features of the application due to the short development time (have to deliver the software tomorrow) If i find a solution in managed code, i will post it here. Thnxs for the pointers however ! On Saturday, February 23, 2008 10:31 AM krach.ara wrote: This worked for me (don't mid the sloppy code.... This worked for me (don't mid the sloppy code.... cleaners are on their way ;) ): public static bool IsValidAttachment(Outlook.MailItem mailitem, Outlook.Attachment attachment) { bool retval = false; string CID = ""; try { if (attachment.FileName != "") { // this skips the olOLE types MAPI.Session session = new Session(); session.Logon("", "", false, false, Type.Missing, Type.Missing, Type.Missing); MAPI.Message message = (MAPI.Message)session.GetMessage(mailitem.EntryID, ""); MAPI.Attachments atts = (Attachments)message.Attachments; for (int teller = 0; teller mailitem.Attachments.Count; teller++) { MAPI.Attachment att = (MAPI.Attachment)atts.get_Item(teller+1); MAPI.Fields fields = (MAPI.Fields)att.Fields; MAPI.Field field = (MAPI.Field)fields.get_Item(MAPI.CdoPropTags.CdoPR _ATTACH_FILENAME, null); if ((string)field.Value == attachment.FileName) { field = (MAPI.Field)fields.get_Item(0x3712001F, null); CID = (string)field.Value; field = (MAPI.Field)fields.get_Item(0x37140003, null); if (!CID.StartsWith(attachment.FileName) && (int)field.Value !=4) retval = true; } } session.Logoff(); } } catch { } if (attachment.Type == Microsoft.Office.Interop.Outlook.OlAttachmentType. olByValue && CID == "") retval = true; return retval; } Submitted via EggHeadCafe - Software Developer Portal of Choice BizTalk Repeating Structures Table Looping and Table Extract http://www.eggheadcafe.com/tutorials...g-structu.aspx |
All times are GMT +1. The time now is 12:31 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-2006 OutlookBanter.com