【问题标题】:Outlook mail integration with .net Desktop applicationOutlook 邮件与 .net 桌面应用程序的集成
【发布时间】:2013-05-15 04:34:30
【问题描述】:

我的系统上运行着窗口应用程序,我可以在其中通过任何地方发送邮件 但我想将我的应用程序集成到 Outlook。

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

【问题讨论】:

标签: c# vb.net winforms windowsformsintegration


【解决方案1】:

执行以下代码:

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#page-2

此链接中给出了逐步实现和解释。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-28
    • 2019-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多