Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
If you have found that accessing a cloud archive folder is not working using the EWS Managed API when the user's mailbox is on-premise then you may need to add some code to your application. To get it to work you will either need to know the password for the archive mailbox or much better is to have password replication setup so that the same password can be used for both the user's mailbox and for their archive. To get to the archive your EWS code will need to first get its SMTP address by calling AutoDiscover for the user in order to get it. Then using that SMTP address your code would call autodiscover again to get the end-point EWS URL of the archive mailbox. After all that your code should be able to use the EWS URL for the archive mailbox, its SMTP address and password to access the mailbox.
You will need two service objects in order to get to the archive mailbox. The first one is to get to the AutoDiscover settings which provide the SMTP address of the archive mailbox. The second service object uses the archive mailbox SMPT address in an AutoDiscover call in order to get the URL for the archive mailbox.
In order for your EWS code to access both the on premise mailbox and the archive mailbox with the same credentials, both need to be set to use the same credentials. This can be done manually or with password replication. If password replication is not setup for your cloud archive then an Exchange Online case should be opened.
Use the EWS Managed API to:
Your going to need to write a little more code to get to the archive folder when the mailbox is on-premise and the archive is in the cloud.
Create a service object and do AutoDiscover on the user mailbox.
Use the service object to do a "GetUserSettings" in order to get back a "GetUserSettingsResponse" object. GetUserSettingsResponse performs a call to the Exchange AutoDiscover service in order to gather user configuration settings.
Below is what the returned XML may look like when the archive mailbox is in the cloud. Note the Type node is set to "Archive" and that there is an SMTPAddress set.:
<UserSetting i:type="AlternateMailboxCollectionSetting">
<Name>AlternateMailboxes</Name>
<AlternativeMailbox>
<Type>Archive</Type>
<DisplayName>In-Place Archive – Bob Smith</DisplayName>
<SmtpAddress>da25f3ab-2939-4f46-8dbd-175c2421c137@mycompany.mail.onmicrosoft.com</SmtpAddress>
<OwnerSmtpAddress> bobsmith@mycompany.com</OwnerSmtpAddress>
</AlternativeMailbox>
</AlternateMailboxes>
</UserSetting>
In comparison, this is what the same setting may look like for an on-premise archive:
<UserSetting i:type="AlternateMailboxCollectionSetting">
<Name>AlternateMailboxes</Name>
<AlternateMailboxes>
<AlternateMailbox>
<Type>Archive</Type>
<DisplayName>Personal Archive - Bob Smith</DisplayName>
<LegacyDN i:nil="true" />
<Server i:nil="true" />
<OwnerSmtpAddress>bobsmith@mycompany.com</OwnerSmtpAddress>
</AlternateMailbox>
</AlternateMailboxes>
</UserSetting>
// The sample below is from "AutodiscoverViewer.cs" in EWSEditor.
case ("Microsoft.Exchange.WebServices.Autodiscover.AlternateMailboxCollection"):
Microsoft.Exchange.WebServices.Autodiscover.AlternateMailboxCollection oCollection3;
oCollection3 = (Microsoft.Exchange.WebServices.Autodiscover.AlternateMailboxCollection)usersetting.Value;
foreach (AlternateMailbox oAlternativeMailbox in oCollection3.Entries)
{
sValue += string.Format(
"Type: {0} \r\n" +
"DisplayName: {1} \r\n" +
"LegacyDN: {2} \r\n" +
"Server: {3} \r\n" +
"SmtpAddress: {4} \r\n" +
"OwnerSmtpAddress: {5} \r\n" +
"\r\n",
oAlternativeMailbox.Type,
oAlternativeMailbox.DisplayName,
oAlternativeMailbox.LegacyDN,
oAlternativeMailbox.Server,
oAlternativeMailbox.SmtpAddress,
oAlternativeMailbox.OwnerSmtpAddress
ValueCount++;
}
To do the same in EWSEditor:
Part 1 - Get the archive mailbox SMTP address.
Part 1 - Get the archive mailbox SMTP address.
Please sign in to use this experience.
Sign in