C# How to get the send of behalf email address in outlook add-in

吃可爱长大的小学妹 提交于 2019-12-12 09:38:45

问题


I'm trying to get the sender email address from email that is send using another email address. The sender as shows in outlook is ditribution-lists@domain.com on behalf of User Name [user.name@domain.com]. The MAPI object has a method SentOnBehalfOfName that returns "User Name" but not the email address. Does anyone know how to receive user.name@domain.com field?


回答1:


using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Reflection;

namespace Helpers
{
    internal class EmailHelper
    {
        public static string GetSenderEmailAddress(Microsoft.Office.Interop.Outlook.MailItem mapiObject)
        {
            Microsoft.Office.Interop.Outlook.PropertyAccessor oPA;
            string propName = "http://schemas.microsoft.com/mapi/proptag/0x0065001F";
            oPA = mapiObject.PropertyAccessor;
            string email = oPA.GetProperty(propName).ToString();
            return email;
        }
    }
}



回答2:


Do you have http://www.dimastr.com/outspy/ ? It is a useful tool for drilling down into MAPI objects in outlook.

Also, if you use http://www.dimastr.com/redemption/ you can get at a SentOnBehalfOfEmailAddress property on the IRDOMail object.




回答3:


If you are using outlook 2007 you have the MailItem.PropertyAccessor and you can get the PR_SENDER_EMAIL_ADDRESS mapi property.

Marcus



来源:https://stackoverflow.com/questions/2244118/c-sharp-how-to-get-the-send-of-behalf-email-address-in-outlook-add-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!