C#如何在outlook中更改Sender字段

时间:2017-01-23 16:19:07

标签: c# outlook vsto

当我在Outlook中创建新邮件(或回复)时,如何将表单"更改为"? mailItem.Sender和SendUsingAccount不起作用。

命名空间OutlookAddIn7 {     public partial class ThisAddIn     {      Outlook.Inspectors检查员;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {

        inspectors = this.Application.Inspectors;
        inspectors.NewInspector +=
        new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(SendUsingAccountExample);

    }
    void SendUsingAccountExample(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    {
        Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
        Outlook.NameSpace session = mailItem.Session;
        Outlook.Accounts accounts = session.Accounts;
        mailItem.SendUsingAccount = Application.Session.Accounts[1];
            //mailItem.Sender = accounts[1].CurrentUser.AddressEntry;
            //Microsoft.Office.Interop.Outlook.Recipient recipient = Application.Session.CreateRecipient(accounts[1].CurrentUser.AddressEntry.Address);
    }

1 个答案:

答案 0 :(得分:0)

如果您使用的是Exchange,请设置SentOnBehalfOfName属性。