bloglobi.blogg.se

Msdn errorprovider
Msdn errorprovider













msdn errorprovider
  1. #Msdn errorprovider update#
  2. #Msdn errorprovider code#

Release COM objects so Outlook will shutdown when requested

msdn errorprovider

Name)) įireContactAddedEvent(this, new ContactEventArgs(newContact, null)) XTrace.WriteInfoLine("PhoneBookSvr", string.Format("GTMM Contact: ", newContact.DisplayAs, newContact.PhoneNumber,

msdn errorprovider

Fire event to add contacts from new Outlook contact XTrace.WriteInfoLine(this.GetType().ToString(), "Firing Contact Added event to ADD all GTMM contacts Outlook Contact after New Outlook Contact") įoreach (IContact newContact in newContacts) IList newContacts = GetOutlookContacts(em)

#Msdn errorprovider update#

Item was added to contacts so update GTMM It is very importand that items and contactFolder don't go out of scope until we finish with event handler

msdn errorprovider

this will start Contact form as modeless dialog box Item.MobileTelephoneNumber = contact.PhoneNumber A new number added to a contact is always a mobile number += new global::Outlook.ItemsEvents_ItemChangeEventHandler(Items_ItemChange) += new global::Outlook.ItemsEvents_ItemChangeEventHandler(this.Items_ItemChange) += new global::Outlook.ItemsEvents_ItemAddEventHandler(this.Items_ItemAdd) ems = (global::Outlook.ItemsClass)Marshal.CreateWrapperOfType(, typeof(global::Outlook.ItemsClass)) notice how you should register these events, cause othervise you will never catch them em = oApp.CreateItem() as MSOutlook.ContactItem ntactFolder = oNameSpace.GetDefaultFolder() Public override void AddContact(IContact contact) This is how AddContact method should look like That is why you are about to see unknown types.

#Msdn errorprovider code#

I appologise for this code is taken from a project which primary purpos was not to demonstrate using of Outlook. Private global::Outlook.ItemsClass items = null Private MSOutlook.MAPIFolder contactFolder = null Private MSOutlook.ContactItem item = null So, declare them globaly (this is conditional) Let'sįirst we need to have some variables which will not go out of scope if we don't want that. This means you need to handle some Outlook events. Let say you need to deal with Outlook contacts (adding new contact, editing, deleting) and that you encapsulate all this in a class. But at the end don't forget to unloas appdomain, i.e. Now you can do all sorts of things with Outlook. ONameSpace.Logon(null, null, true, true) MSOutlook._Namespace oNameSpace = oApp.GetNamespace("MAPI") MSOutlook.Application oApp = (MSOutlook.Application)(assemblyType) assemblyOutlook = oAppDomain.Load(strAssemblyName) Load that assembly in newly created appdomain Type assemblyType = typeof(MSOutlook.ApplicationClass) // all we need is one type from NetOutlook assembly Here we are going to call Interop.Outlook assembly just MSOutlook So, first you need to create new application domainĪppDomain oAppDomain = AppDomain.CreateDomain("Outlook") Since second solution is more complicated and more general I'll present that Kill it by shutting down client application, or you are going to use separate application domain to run Outlook. Now before you are start Outlook (before you instantiate Outlook, to be more precise), you must decide if you are going to keep Outlook resident in memory after you finish with it and to Project references (you can find them under COM tab). What you should do?įirst you need to know that MS has shipped PIA (Primary Interop Assemblies) throug MS Office instalation (this must be checked in installation options). Let say you need to create Outlook add-in in.















Msdn errorprovider