Reputation: 4287
I am trying to use the following code sample from msdn:
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")
{
//This rows gives an error:
//Microsoft.Office.Interop.Outlook.MailItem does not contain a definition for Sender
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();
return (exchUser != null) ? exchUser.PrimarySmtpAddress : null;
}
return sender.PropertyAccessor.GetProperty(PR_SMTP_ADDRESS) as string;
}
return null;
}
return mail.SenderEmailAddress;
}
But for some reason I'm getting this compile error:
'Microsoft.Office.Interop.Outlook.MailItem' does not contain a definition for 'Sender'
and no extension method 'Sender' accepting a first argument of type
'Microsoft.Office.Interop.Outlook.MailItem' could be found
(are you missing a using directive or an assembly reference?)
I'm using winforms with framework 3.5, wat can I do...?
Upvotes: 1
Views: 1760
Reputation: 49397
See HowTo: Convert Exchange-based email address into SMTP email address . It supports earlier Outlook versions.
P.S. You may check the Outlook interop reference by choosing it in the Solutions Explorer window. In the Properties window will find its version.
Upvotes: 1