Код: Выделить всё
var exchangeUser = addressEntry.GetExchangeUser();
if (exchangeUser != null)
{
//... get smtp exchangeUser.PrimarySmtpAddress
}
else
{
//... try find smtp by:
var propertyEmailAttempt1 = addressEntry.PropertyAccessor.GetPropertySafe("0x39FE001F");
var propertyEmailAttempt2 = addressEntry.PropertyAccessor.GetPropertySafe("0x800F101F");
var propertyEmailAttempt3 = addressEntry.PropertyAccessor.GetPropertySafe("0x39FE001E");
}
< /code>
Во всех случаях свойства возвращают null. < /p>
public static dynamic GetPropertySafe(this Microsoft.Office.Interop.Outlook.PropertyAccessor propertyAccessor, string tag)
{
try
{
return propertyAccessor.GetProperty($"http://schemas.microsoft.com/mapi/proptag/{tag}");
}
catch
{
//Property is most likely not found
return null;
}
}
// Is not resolved and does not contain @.
if (!recipient.Resolved && recipient.AddressEntry?.Address?.Contains("@") == false)
{
// Try first resolve.
recipient.Resolve();
Trace.WriteLine($"Recipient EX second resolved: {recipient.Resolved} - {appOutlook.Session.Offline}");
// Now resolved?
if (!recipient.Resolved && appOutlook.Session.Offline == false)
{
string address = $"{recipient.Address}";
// Create entry.
Recipient tempRecipient = appOutlook.Session.CreateRecipient(address);
tempRecipient.Resolve();
Trace.WriteLine($"TempRecipient EX resolved: {tempRecipient.Resolved} - {address}");
if (tempRecipient.Resolved)
{
var result = IsExchangeUser(tempRecipient.AddressEntry, type);
Marshal.ReleaseComObject(tempRecipient);
return result;
}
}
}
< /code>
Однако в моих тестах, с адресом x400, который я использовал для своих тестов, никогда не решайте на последнем шаге: < /p>
Recipient tempRecipient = appOutlook.Session.CreateRecipient(address);
tempRecipient.Resolve();
< /code>
У меня нет идей о том, как это исправить. Возможным предложением в Интернете было использование выкупа Outlook. Однако остается вопрос, могу ли я исправить это с помощью выкупа Outlook?
Подробнее здесь: https://stackoverflow.com/questions/794 ... 00-address
Мобильная версия