2010-02-11 26 views
6

Gönderenin e-posta adresini başka bir e-posta adresi kullanarak gönderen e-posta adresine almaya çalışıyorum. Görünüşte gösterilen gönderen, Kullanıcı Adı [[email protected]] adına [email protected] adresidir. MAPI nesnesi, "Kullanıcı Adı" döndüren ancak e-posta adresini döndürmeyen SentOnBehalfOfName yöntemine sahiptir. [email protected] alan adını nasıl alacağını bilen var mı?C# Nasıl görünüme eklenti e-posta adresi göndermek için eklenti

cevap

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

Eğer outlook 2007 kullanıyorsanız, MailItem.PropertyAccessor'a sahip olursunuz ve PR_SENDER_EMAIL_ADDRESS mapi özelliğini alabilirsiniz.

Marcus