在我的WPF应用程序中,我创建并显示了如下所示的MailItem:
using Microsoft.Office.Interop.Outlook;
Application outlook = new Application();
NameSpace ns = outlook.GetNamespace("MAPI");
MailItem mailItem = outlook.CreateItem(OlItemType.olMailItem);
mailItem.Display(false);
string lastEntryId = mailItem.EntryID; // remember EntryId用户现在可以撰写和发送邮件了。
在用户发送邮件后,他在我的应用程序中确认发送。然后,我的应用程序应该将邮件保存在文件系统中。我的方法是“记住”MailItem.EntryID在发送后使用它。
// ... lastEntryId is null therefore this code doesn't work
MailItem mailItem = ns.GetItemFromID(lastEntryId);
string fileName = GetValidFileName(item.Subject) + ".msg";
string file = Path.Combine(GetSaveDirectory(), fileName);
item.SaveAs(file);但是lastEntryId在发送之前是null的,所以我不能使用它。
问题是: MailItem发送后如何访问?
发布于 2020-04-21 01:12:41
即使您在发送邮件之前拥有条目id,当邮件发送并移动到“已发送邮件”文件夹时,条目id也会发生变化。它只在PST商店下保持不变。
“已发送邮件”文件夹上的Items.ItemAdd事件是您可以访问已发送邮件的最早时间。
如果您不关心消息是否处于已发送状态,也可以使用Application.ItemSend事件。
https://stackoverflow.com/questions/61318218
复制相似问题