【发布时间】:2020-10-05 22:10:19
【问题描述】:
Microsoft.Office.Interop.Outlook.Application app = (Microsoft.Office.Interop.Outlook.Application)OutlookApp.Application;
AttachmentList = new List<Microsoft.Office.Interop.Outlook.Attachment>();
TotalAttachmentList = new List<Microsoft.Office.Interop.Outlook.Attachment>();
object objMailItem = app.ActiveWindow();
Controler.Utility.SenderEmailId = Sendername;
object context = control.Context;
if (context is Outlook._Inspector)
{
Outlook.Inspector insp = context as Outlook.Inspector;
object item = insp.CurrentItem;
if (item is Outlook._MailItem)
{
Outlook._MailItem mail = item as Outlook._MailItem;
// do something with the email
MailSubject = mail.Subject;
Body = mail.Body;
for (int attchCount = 1; attchCount <= mail.Attachments.Count; attchCount++)
{
if (mail.Attachments.Count > 0)
{
for (int i = 1; i <= mail.Attachments.Count; i++)
{
AttachmentList.Add(mail.Attachments)
}
}
}
}
Marshal.ReleaseComObject(item); item = null;
}
Marshal.ReleaseComObject(context); context = null;
}
【问题讨论】:
-
一个疯狂的猜测:不应该是
AttachmentList.Add(mail.Attachments[i])吗? -
有什么建议吗?
-
其他? - 可能不是。您是否应用了更改?
标签: c# .net outlook-addin add-in