View Single Post
  #5  
Old February 21st 08, 10:44 AM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 3
Default 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;
}
Ads