Simon
Simon

Reputation: 4844

How can we access the exchange mailboxes via EWS when the user has no own mailbox?

We want to access mailboxes via EWS (Exchange Web Services) with an dedicated user who has no own mailbox.

The target is to cover all Exchange Server version 2007-2019.

Reason why we want to have an dedicated user with no mailbox: We want analyze all mailboxes in an Exchange Server by an software. But therefore we not really need an user and even an mailbox. Only the data inside the mailboxes are interesting for the software.

We use Independentsoft´s API to access the EWS:

var lCredential = new NetworkCredential("ADUserWithNoMailbox", "Password");
m_Service = new Service("https://hostname/EWS/Exchange.asmx", lCredential);

try
{
    FindFolderResponse lResponse = m_Service.FindFolder(StandardFolder.MailboxRoot);
    
    // [...]
}
catch (Exception e)
{
    // cast in into multiple expected types
    var lServiceRequestException = e as Independentsoft.Exchange.ServiceRequestException;

    if (lServiceRequestException.ResponseCode == "ErrorNonExistentMailbox")
    {
        // lServiceRequestException.Message shows: "No mailbox with such guid."
        // [...]
    }
    
    // [...]
    
    throw;
}

Our user ADUserWithNoMailbox which is in the Active Directory has no mailbox. Therefore an exception occurs with the message:

"No mailbox with such guid."

Question: How can we access the exchange mailboxes via EWS when the user has no own mailbox?

Upvotes: 0

Views: 1475

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

It should work okay if the servers are patched to the correct levels eg there can be problem like https://support.microsoft.com/en-us/topic/-the-smtp-address-has-no-mailbox-associated-with-it-error-when-you-access-a-user-s-mailbox-by-using-ews-application-c8e31e36-b6e2-229e-cc78-305ab9fea94a. I've always found this to be problematic if your deploying apps in different customer environments and found for most OnPrem deployments giving the Service account your using a Mailbox is not a problem, to stop it appearing in address lists most customers can just hide it. (Office365 is a different matter because of the cost of consuming a licence but you can use App tokens which don't require a user or mailbox)

Probably for your requirement using EWS Impersonation https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/impersonation-and-ews-in-exchange is a better option as that will give you access to all Mailboxes.

Upvotes: 0

Related Questions