Salut, je reviens toujours sur un Addin que je developpe pour Outlook, en fait j'ai créer des sous dossiers dans la boite de reception de Outlook qui devrai contenir un type de mail spécifique , comme des filtre dans les web mail comm Yahoo.
Alors j'ai placé mon code dans le fichier connect.cs, je vous en donne un extrait du contenu:
Mais je suis surpris ke lorsque je reçoi un mail contenant le filtre, le deplacement ne se fait..Alors je ne comprends plus rien alors ke le code marche indépendament...
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 #region OnStartupComplete public void OnStartupComplete(ref System.Array custom) { #region variables CommandBars oCommandBars;// Collection des commandbars de l'application hôte CommandBar oStandardBar;// Notre barre d'outils Outlook.MAPIFolder oFolderSMS;//les sous dossiers Notifications SMS Outlook.MAPIFolder oFolderMMS;//les sous dossiers Notifications MMS Outlook.MAPIFolder oFolderFax;//les sous dossiers Notifications Fax #endregion #region Création des sous dossiers de notification //Applictaion Outlook Outlook.ApplicationClass OutlookApp = new Outlook.ApplicationClass(); //le dossier InBox Outlook.NameSpace OutlookNameSpace = OutlookApp.GetNamespace("MAPI"); Outlook.MAPIFolder oInbox = OutlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); Outlook.Folders oFolders = oInbox.Folders; //sous dossiers de Notification (SMS, MMS, Fax) try { oFolderSMS = oInbox.Folders["Notifications SMS"]; oFolderMMS = oInbox.Folders["Notifications MMS"]; oFolderFax = oInbox.Folders["Notifications Fax"]; } catch (Exception) { oFolderSMS = oFolders.Add("Notifications SMS", Outlook.OlDefaultFolders.olFolderInbox); oFolderMMS = oFolders.Add("Notifications MMS", Outlook.OlDefaultFolders.olFolderInbox); oFolderFax = oFolders.Add("Notifications Fax", Outlook.OlDefaultFolders.olFolderInbox); } #endregion #region NewMailExEventHandler OutlookApp.NewMail += new Outlook.ApplicationEvents_11_NewMailEventHandler(this.Outlook_NewMail); #endregion ...... public void Outlook_NewMail() { try { //Applictaion Outlook Outlook.ApplicationClass OutlookApp = new Outlook.ApplicationClass(); //le dossier InBox Outlook.NameSpace OutlookNameSpace = OutlookApp.GetNamespace("MAPI"); Outlook.MAPIFolder oInbox = OutlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); //collection de mails récus Outlook.Items oItems = (Outlook.Items)oInbox.Items; //les mails non lus oItems.Restrict("[UnRead] = true"); //les Filtres string filtreSMS = "Accusé d'émission de SMS avec succès"; string filtreMMS = "Accusé d'émission de MMS avec succès"; string filtreFax = "Accusé d'émission de Fax avec succès"; //le premier mail Outlook.MailItem unReadMails = (Outlook.MailItem)oItems.GetFirst(); //Traitement pour chaque nouveau mail reçu while (unReadMails != null) { //déplacement des mails if (unReadMails.Subject.Contains(filtreSMS)) unReadMails.Move(oInbox.Folders["Notifications SMS"]); if (unReadMails.Subject.Contains(filtreMMS)) unReadMails.Move(oInbox.Folders["Notifications MMS"]); if (unReadMails.Subject.Contains(filtreFax)) unReadMails.Move(oInbox.Folders["Notifications Fax"]); //next unReadMails = (Outlook.MailItem)oItems.GetNext(); } } catch (Exception ex){ MessageBox.Show("Exception produite" + ex); } }
Je demande votre aide.
Partager