Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 [email protected] on behalf of User Name [[email protected]]. The MAPI object has a method SentOnBehalfOfName that returns "User Name" but not the email address. Does anyone know how to receive [email protected] field?

like image 355
Alin Avatar asked Feb 11 '10 11:02

Alin


2 Answers

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;
        }
    }
}
like image 129
Alin Avatar answered Sep 21 '22 02:09

Alin


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.

like image 26
Eric Dahlvang Avatar answered Sep 20 '22 02:09

Eric Dahlvang