开发者

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

开发者 https://www.devze.com 2022-12-19 17:34 出处:网络
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

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 ret开发者_JAVA百科urns "User Name" but not the email address. Does anyone know how to receive user.name@domain.com field?


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


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.


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

Marcus

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号