我正在尝试创建一个Outlook添加,其中我们有2个电子邮件帐户,我想将回复邮件设置为默认邮件集。目前,发送电子邮件默认为发送到的帐户。我已经在线查看并查看了类似的帖子,但是一旦我关闭电子邮件消息,代码就不会设置我选择的默认电子邮件了。你能帮忙吗?以下是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using System.DirectoryServices.AccountManagement;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace OutlookAddIn1{
public partial class ThisAddIn
{
private Outlook.Inspectors inspectors;
private Outlook.Accounts accounts;
private Outlook.MailItem mailItem;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
inspectors = this.Application.Inspectors;
inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
}
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
mailItem =Inspector.CurrentItem;
accounts = Application.Session.Accounts;
if (mailItem != null)
{
if (mailItem.EntryID == null)
{
foreach (Outlook.Account account in accounts)
{
String strname = "xxxx";
if (account.SmtpAddress.ToString().IndexOf(strname)>0)
{
mailItem.SendUsingAccount =account;
}
}
}
}
}
}
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
非常感谢!