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;
} |