title: Outlook.MailItem.Sender is null- to fetch From email address
body: <p>I am trying to create Outlook Addin using C#. Customizing <code>Application_ItemSend</code> event of the <code>Send</code> button.</p>
  
  <p>I am unable to get from/sender email address. I am getting following things as null:</p>
  
  <ul>
  <li><code>Outlook.MailItem.SenderEmailType</code></li>
  <li><code>Outlook.MailItem.Sender</code> (as this is null not able to get PrimarySmtpAddress)</li>
  <li><code>Outlook.MailItem.SenderEmailAddress</code></li>
  </ul>
  
  <p>Any pointers what is wrong? Is it my outlook account is incorrectly configured?</p>
  
  <p>Any help appreciated. Thanks in advance.</p>
  
  <p>Below is the code to fetch address which i am using:</p>
  
  <pre><code> private string GetSenderSMTPAddress(Outlook.MailItem mail)
      {
          string PR_SMTP_ADDRESS =   @"http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
          if (mail == null)
          {
              throw new ArgumentNullException();
          }
          if (mail.SenderEmailType == "EX")
          {
              Outlook.AddressEntry sender =
                  mail.Sender;
              if (sender != null)
              {
                  //Now we have an AddressEntry representing the Sender
                  if (sender.AddressEntryUserType ==
                      Outlook.OlAddressEntryUserType.
                      olExchangeUserAddressEntry
                      || sender.AddressEntryUserType ==
                      Outlook.OlAddressEntryUserType.
                      olExchangeRemoteUserAddressEntry)
                  {
                      //Use the ExchangeUser object PrimarySMTPAddress
                      Outlook.ExchangeUser exchUser =
                          sender.GetExchangeUser();
                      if (exchUser != null)
                      {
                          return exchUser.PrimarySmtpAddress;
                      }
                      else
                      {
                          return null;
                      }
                  }
                  else
                  {
                      return sender.PropertyAccessor.GetProperty(
                          PR_SMTP_ADDRESS) as string;
                  }
              }
              else
              {
                  return null;
              }
          }
          else
          {
              return mail.SenderEmailAddress;
          }
      }
  </code></pre>