当前位置: 首页 > 知识库问答 >
问题:

Verfiy a SMTP address is associated with a mailbox

解柏
2023-03-14

Is there any easy/elegant way to verify, that a SMTP address is associated with an Exchange mailbox via EWS?
Credentials of an administrative Exchange user are given.

Problem:
Not that elegant to compare the exception message
Takes about 200-250ms per user (not parallel)

Another Problem:
It is possible, that there are contacts in the GAL, that don't have a mailbox.
So ResolveNames won't be helpful.

共有1个答案

郎言
2023-03-14

The easiest way is to use the ResolveName operation and search the Directory you just need to prefix the address with smtp: and Exchange will the search both the Primary and proxyaddressses eg

String EmailAddresstoCheck = "info@domain.com";
NameResolutionCollection ncCol = service.ResolveName(("SMTP:" + EmailAddresstoCheck), ResolveNameSearchLocation.DirectoryOnly, true);
if (ncCol.Count == 1)
{
    if (ncCol[0].Contact != null)
    {
        if (EmailAddresstoCheck.ToLower() == ncCol[0].Mailbox.Address)
        {
            Console.WriteLine("Primary SMTP Address of " + ncCol[0].Contact.DisplayName);
        }
        else                             
        {
            Console.WriteLine("Proxy Address of " + ncCol[0].Contact.DisplayName);
            Console.WriteLine("Primary SMTP Address : " + ncCol[0].Mailbox.Address);
        }                    
    }                
}

Cheers Glen

 类似资料:

相关问答

相关文章

相关阅读