Outlook邮件集成与.net桌面应用程序

本文关键字:net 桌面 应用程序 集成 Outlook | 更新日期: 2023-09-27 18:13:41

我有一个窗口应用程序在我的系统上运行,我可以通过任何地方发送邮件但是我想把我的应用程序集成到outlook中。

1。已发送的邮件应显示在outlook已发送邮件文件夹中。2.如果邮件发送失败,它应该显示在outlook的发件箱文件夹

Outlook邮件集成与.net桌面应用程序

检查以下代码:

Outlook.Application oApp = new Outlook.Application();
if (this.listViewContacts.SelectedItems != null &&
this.listViewContacts.SelectedItems.Count > 0)
{
Outlook.ContactItem oRecip = (Outlook.ContactItem)
(this.listViewContacts.SelectedItems[0].Tag);
Outlook.MailItem email = (Outlook.MailItem)
(oApp.CreateItem(Outlook.OlItemType.olMailItem));
email.Recipients.Add(oRecip.Email1Address);
email.Subject = "Just wanted to say...";
email.Body = "Have a great day!";
if (MessageBox.Show(
"Are you sure you want to send a good day message to " +
oRecip.Email1DisplayName + "?", "Send?",
MessageBoxButtons.OKCancel)
== DialogResult.OK)
{
try
{
((Outlook.MailItem)email).Send();
MessageBox.Show("Email sent successfully.", "Sent");
}
catch (Exception ex)
{
MessageBox.Show("Email failed: " + ex.Message,
"Failed Send");
}
}
oRecip = null;
email = null;
}

参考链接:

http://www.codeguru.com/csharp/csharp/cs_misc/e-mail/article.php/c14293/Microsoft-Outlook-Integration-with-CNET.htm第2页

在这个链接中给出了一步一步的实现和解释。