嗨,我必须使用 C# 从 Outlook 2010 的本地目录中分别读取附件和内联图像。我为此使用了属性和内容 ID 概念。我正在使用以下代码来执行此操作,但它现在正在工作。
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);
}
}
}
请帮助正在进行的工作....