嗨我必須從使用C#的Outlook 2010在本地目錄中單獨閱讀附件和內聯圖片。我爲此使用了屬性和內容ID概念。我正在使用下面的代碼來做這件事,但它現在正在工作。如何在Outlook 2010中區分內聯圖片和附件[C#]
if (mailItem.Attachments.Count > 0)
{
/*for (int i = 1; i <= mailItem.Attachments.Count; i++)
{
string filePath = Path.Combine(destinationDirectory, mailItem.Attachments[i].FileName);
mailItem.Attachments[i].SaveAsFile(filePath);
AttachmentDetails.Add(filePath);
}*/
foreach (Outlook.Attachment atmt in mailItem.Attachments)
{
MessageBox.Show("inside for each loop");
prop = atmt.PropertyAccessor;
string contentID = (string)prop.GetProperty(SchemaPR_ATTACH_CONTENT_ID);
MessageBox.Show("content if is " +contentID);
if (contentID != "")
{
MessageBox.Show("inside if loop");
string filePath = Path.Combine(destinationDirectory, atmt.FileName);
MessageBox.Show(filePath);
atmt.SaveAsFile(filePath);
AttachmentDetails.Add(filePath);
}
else
{
MessageBox.Show("inside else loop");
string filePath = Path.Combine(destinationDirectoryT, atmt.FileName);
atmt.SaveAsFile(filePath);
AttachmentDetails.Add(filePath);
}
}
}
請幫助工作正在進行中....
串SchemaPR_ATTACH_CONTENT_ID = @ 「http://schemas.microsoft.com/mapi/proptag/0x3712001E」; – zytham