繁体   English   中英

C# 如何在 Outlook 中更改发件人字段

[英]C# how change Sender field in outlook

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

命名空间 OutlookAddIn7 { 公共部分类 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);
    }

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM