Доброго всем дня.
Хочу использовать Exchange WS notification:
Делаю соединение:
private bool InitEWS()
{
if (_service != null) return true;
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
try
{
switch (comboBoxExchangeVersion.Text)
{
case "Exchange2007_SP1": _service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); break;
case "Exchange2010": _service = new ExchangeService(ExchangeVersion.Exchange2010); break;
case "Exchange2010_SP1": _service = new ExchangeService(ExchangeVersion.Exchange2010_SP1); break;
case "Exchange2010_SP2": _service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); break;
default: _service = new ExchangeService(); break;
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "Failed to create service",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (!String.IsNullOrEmpty(textBoxUsername.Text))
{
_service.Credentials = new WebCredentials(textBoxUsername.Text, textBoxPassword.Text);
}
_service.TraceListener = _traceListener;
_service.TraceFlags = TraceFlags.All;
_service.TraceEnabled = true;
try
{
_service.AutodiscoverUrl(textBoxMailbox.Text, RedirectionUrlValidationCallback);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "Failed to autodiscover URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}
и подписываюсь
FolderId[] folders=new FolderId[1];
folders[0] = new FolderId(WellKnownFolderName.Inbox);
_subscription = _service.[b]SubscribeToStreamingNotifications[/b](folders, SelectedEvents());
private EventType[] SelectedEvents()
{
// Read the selected events
if (checkedListBoxEvents.CheckedItems.Count < 1)
return null;
EventType[] events = new EventType[checkedListBoxEvents.CheckedItems.Count];
for (int i = 0; i < checkedListBoxEvents.CheckedItems.Count; i++)
{
switch (checkedListBoxEvents.CheckedItems[i].ToString())
{
case "NewMail": { events[i] = EventType.NewMail; break; }
case "Deleted": { events[i] = EventType.Deleted; break; }
case "Modified": { events[i] = EventType.Modified; break; }
case "Moved": { events[i] = EventType.Moved; break; }
case "Copied": { events[i] = EventType.Copied; break; }
case "Created": { events[i] = EventType.Created; break; }
case "FreeBusyChanged": { events[i] = EventType.FreeBusyChanged; break; }
}
}
return events;
}
ПРОБЛЕМА - Я получаю только сообщения о изминении для того пользователя с которым я делаю соединение!
НАДО - смотреть для всех !!!
СПАСИБО!