【发布时间】:2015-05-06 09:49:52
【问题描述】:
我正在使用 Outlook.Application 和 Outlook.MailItem 对象在我的 C# 桌面应用程序中打开 Outlook。我的 Outlook 不显示附件,尽管当我向自己发送邮件时,我收到带有附件的邮件。但它在发送邮件之前没有显示(当 Outlook 打开时)。我正在使用 Outlook 2007。下面是我的代码:
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using a dialog box to choose the profile.
oNS.Logon(Missing.Value, Missing.Value, true, true);
// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
......
//Check if we need to add attachments
if (_files.Count > 0)
{
foreach (string attachment in _files)
{
oMsg.Attachments.Add(attachment,Outlook.OlAttachmentType.olByValue,null,null);
}
}
oMsg.Save();
oMsg.Display(false);
【问题讨论】:
-
格式更清晰会更好。我会自己做,但编辑按钮是灰色的。
-
代码现在已格式化。谢谢。
-
我能够通过将附件行替换为以下内容来解决上述问题:oMsg.Attachments.Add(attachment, Outlook.OlAttachmentType.olByValue,Type.Missing,Type.Missing);