Differenciate or distinguish between outlook attachment and embedded image/signature using property ...

本文介绍如何在Outlook自动化程序中处理RTF格式邮件的附件问题,特别是当邮件包含内嵌图片或签名时,如何正确识别并过滤这些元素,避免将其误认为实际附件。
These days, outlook emails are composed in three formats; plain text, html and rtf (rich text format). If an email is in rtf and it has attachments, as well as, embedded image or signature, it poses a problem in outlook automation. When you are reading attachments in an outlook automation program, your program will recognize the embedded image/signature as an attachment. Although, it is not an attachment from the sender. So, you need to apply some sort of filtering in your loop. Here it is……

using System;
using System.Collections.Generic;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.IO;

            Outlook.MailItem item = null;
            Outlook.PropertyAccessor prop;

           // intialize item to a mail item
            foreach (Outlook.Attachment atmt in item.Attachments)
            {
                            prop = atmt.PropertyAccessor;

                            string contentID = (string)prop.GetProperty(“http://schemas.microsoft.com/mapi/proptag/0x3712001E“);

                            if (contentID != “”)
                                continue;

                            else

                                   //do something

                            ; 

        }

If the ContentID is not found, it is not an actual attachment, rather an embedded image/signature.

 

转载于:https://www.cnblogs.com/lee2011/p/10655113.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值