Я решил проблему сам.Пример подключения к сервису:
public static class ConnectionToEws
{
private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
bool result = false;
var redirectionUri = new Uri(redirectionUrl);
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
public static ExchangeService ConnectToService()
{
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
{
Credentials = new WebCredentials("Login", "Password")
,UseDefaultCredentials = false
};
service.AutodiscoverUrl("EmailAddress", RedirectionUrlValidationCallback);
return service;
}
}
Пример получения EntryId:
static void Main(string[] args)
{
var service = ConnectionToEws.ConnectToService();
var results = service.FindItems(WellKnownFolderName.Inbox, new ItemView(1));
foreach (var item in results)
{
var originalId = new AlternateId(IdFormat.EwsId, item.Id.ToString(), "EmailAddress", false);
var entryId = service.ConvertId(originalId, IdFormat.HexEntryId);
Console.WriteLine(((AlternateId)entryId).UniqueId);
}
Console.ReadKey();
}
Вариант для публичного польдера:
static void Main(string[] args)
{
var service = ConnectionToEws.ConnectToService();
var someFolder = GetFolder(service, "MyFolderName");
var results = someFolder.FindItems(new ItemView(1));
foreach (var item in results)
{
var alternatePublicFolderItem = new AlternatePublicFolderItemId(IdFormat.EwsId, someFolder.Id.UniqueId, item.Id.ToString());
var convertResult = service.ConvertId(alternatePublicFolderItem, IdFormat.HexEntryId);
Console.WriteLine(((AlternatePublicFolderItemId)convertResult).ItemId);
}
Console.ReadKey();
}
private static Folder GetFolder(ExchangeService service, string folderName)
{
var folderView = new FolderView(int.MaxValue);
var findFolderResults = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, folderView);
foreach (var folder in findFolderResults)
{
if (folderName.Equals(folder.DisplayName, StringComparison.InvariantCultureIgnoreCase))
{
return folder;
}
}
return null;
}