Bonjour a tous !
Je souhaite créer une classe qui puisse me permettre de créer des contacts et des listes de distributions automatiquement !
Pour les contacts, je n'ai pas trop de pb, mais pour les liste j'ai qq soucis !
Voici un bout de mon code :
Ici, je crée bien dans Outlook 2003 mes contacts et mes listes VIERGES !
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 using System; using Outlook = Microsoft.Office.Interop.Outlook; using MSN = MessengerAPI; public class MessengerToOutlook { private Outlook._Application _application; private Outlook._NameSpace _namespace; private Outlook._ContactItem _contactItem; private Outlook._DistListItem _distListItem; private Outlook.MAPIFolder _mapiFolder; private Outlook.Items _items; public MessengerToOutlook() { this._application = new Outlook.ApplicationClass(); this._namespace = this._application.GetNamespace("MAPI"); this._mapiFolder = this._namespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); } // Transformation de contact MSN en contact Outlook public object MessengerBuddyToOutlookContact(object MessengerBuddy) { this._items = this._mapiFolder.Items; this._contactItem = (Outlook._ContactItem)this._items.Add("IPM.Contact"); this._contactItem.Email1Address = ((MSN.IMessengerContact)MessengerBuddy).SigninName; this._contactItem.MobileTelephoneNumber = ((MSN.IMessengerContact)MessengerBuddy).get_PhoneNumber(MSN.MPHONE_TYPE.MPHONE_TYPE_MOBILE); this._contactItem.HomeTelephoneNumber = ((MSN.IMessengerContact)MessengerBuddy).get_PhoneNumber(MSN.MPHONE_TYPE.MPHONE_TYPE_HOME); this._contactItem.BusinessTelephoneNumber = ((MSN.IMessengerContact)MessengerBuddy).get_PhoneNumber(MSN.MPHONE_TYPE.MPHONE_TYPE_WORK); this._contactItem.FirstName = ((MSN.IMessengerContact)MessengerBuddy).SigninName.Substring(0,((MSN.IMessengerContact)MessengerBuddy).SigninName.IndexOf("@")); this._contactItem.Save(); return this._contactItem; } // Transformation d'un groupe MSN en Liste public object MessengerGroupToOutlookDistList(object MessengerGroup) { this._items = this._mapiFolder.Items; this._distListItem = (Outlook._DistListItem)this._items.Add("IPM.DistList"); this._distListItem.DLName = ((MSN.IMessengerGroup)MessengerGroup).Name; this._distListItem.Save(); return this._distListItem; }
Voilà ou ca coince :
Ici, je ne comprends pas tres bien !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 // Ajout d'un contact a une liste public void AddContactToDistList(object Contact,object DistList) { this._contactItem = (Outlook._ContactItem)Contact; this._distListItem = (Outlook._DistListItem)DistList; Outlook.Recipient recipient = this._namespace.CreateRecipient(this._contactItem.Email1Address); this._distListItem.AddMember(recipient); }
En effet, si j'execute le code, il n'ajoute pas les contacts aux listes !
Cepedant, si je fais un breakpoint sur l'ajout du membre a la liste et que j'espionne le recipient puis que je continue l'execution j'ai bien qq chose dans ma liste...
Merci de votre aide...
Partager