我有C#
个应用程序,它使用Microsoft.Office.Interop.Outlook
发送电子邮件。一切正常,我在下面附上了部分代码:
// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
// Add email info text.
oMsg.HTMLBody = m_eMailBody;
oMsg.Subject = m_mailSubject;
// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(hostEmail);
oRecip.Resolve();
// Send E-Mail via Outlook.
try
{
((Outlook._MailItem)oMsg).Send();
}
catch (Exception ex)
{
...
调用Send()
后,可能会发生两件事:
我尝试使用(Outlook._MailItem)oMsg).Sent
,但它只是抛出异常。
有没有办法真正发现电子邮件是否真的被发送,有什么想法吗?