Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Outlook邮件与.net桌面应用程序的集成_C#_Vb.net_Winforms_Windowsformsintegration - Fatal编程技术网

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

C# Outlook邮件与.net桌面应用程序的集成,c#,vb.net,winforms,windowsformsintegration,C#,Vb.net,Winforms,Windowsformsintegration,我的系统上运行着一个窗口应用程序,我可以在任何地方发送邮件 但我想将我的应用程序集成到outlook 1.已发送邮件应显示在outlook已发送邮件文件夹中。 2.如果邮件发送失败,它应显示在outlook的发件箱文件夹中,请执行以下代码: Outlook.Application oApp = new Outlook.Application(); if (this.listViewContacts.SelectedItems != null && this.listViewCo

我的系统上运行着一个窗口应用程序,我可以在任何地方发送邮件 但我想将我的应用程序集成到outlook

1.已发送邮件应显示在outlook已发送邮件文件夹中。
2.如果邮件发送失败,它应显示在outlook的发件箱文件夹中,请执行以下代码:

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;
}
参考链接:

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;
}

本链接中给出了一步一步的实现和解释


<>希望有帮助。

根据您的项目,您可能需要考虑构建Outlook Advin?见: