Bonjour à tous,
J'ai développé un programme permettant de récupérer et traiter les mails d'une BAL grâce à EWS.
Il n'y a eu aucun problème jusqu'à ce que subitement, je n'ai plus de notifications lorsque je reçois, supprime ou modifie un mail.
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 //Méthode Pour Connection Au Stream De La BAL public static void SetStreamingNotifications(ExchangeService service) { try { StreamingSubscription streamingsubscription = service.SubscribeToStreamingNotifications( new FolderId[] { WellKnownFolderName.Inbox }, EventType.NewMail); StreamingSubscriptionConnection connection = new StreamingSubscriptionConnection(service, 3); connection.AddSubscription(streamingsubscription); connection.OnNotificationEvent += new StreamingSubscriptionConnection.NotificationEventDelegate(OnEvent); connection.OnSubscriptionError += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnError); connection.OnDisconnect += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnDisconnect); connection.Open(); MessageBox.Show("Connection au streaming de la BAL"); } catch (Exception ex) { MessageBox.Show("Erreur :" + ex); } }Le code passe bien dans la méthode OnDisconnect, en revanche il n'en ait rien pour la méthode OnEvent. Et tout cela subitement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 //Methode pour gérer la deconnection private static void OnDisconnect(object sender, SubscriptionErrorEventArgs args) { StreamingSubscriptionConnection connection = (StreamingSubscriptionConnection)sender; DialogResult dialogResult = MessageBox.Show("Voulez-vous vous reconnecter ?", "Reconnection", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { connection.Open(); } else if (dialogResult == DialogResult.No) { } } //Méthode pour gérer les événements private static void OnEvent(object sender, NotificationEventArgs args) { StreamingSubscription subscription = args.Subscription; foreach (NotificationEvent notification in args.Events) { switch (notification.EventType) { case EventType.NewMail: MessageBox.Show("Mail created"); break; case EventType.Created: MessageBox.Show("Mail or folder created"); break; case EventType.Deleted: MessageBox.Show("Mail or folder deleted"); break; case EventType.Moved: MessageBox.Show("Mail or folder Moved"); break; case EventType.Modified: MessageBox.Show("Mail or folder Modified"); break; } if (notification is ItemEvent) { ItemEvent itemEvent = (ItemEvent)notification; MessageBox.Show("ItemId: " + itemEvent.ItemId.UniqueId); } else { FolderEvent folderEvent = (FolderEvent)notification; MessageBox.Show("FolderId: " + folderEvent.FolderId.UniqueId); } } }
Est-ce un problème du côté de Exchange ?
Merci de votre aide.
Partager