![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi,
I have tried several ways (lates code snippet is at the end of the message) and have observered many questions all over the web - but none of the code snippets seem to apply to my environment exactly. The problem is simple ....when I "open" an "existing" contact I want to add a couple text boxes and command buttons to the "general" tab. So I figured I would design a custom contacts form and save it which I did. Ultimately I want to capture the new inspector event and replace the default contacts form (IPM.Contact) with my form and populate the existing data into my new form, plus add new information to the new text boxes that I created. I found some sample code at http://www.codeproject.com/com/OutlookForms.asp and I thought I would be able to use that code within the "OnNewInspector" event. No matter what I do I cannot get the new form to load. the default form keeps loading. I do want to use the default form for creating NEW contacts, however to open or view the contact I want to use my custom form. I do know that deleting or saving a form greatly affects the Outlook defaults and I truly do not believe this is the correct method to employ. BTW - if I manually - as a user - Publish the form and make my custom form the default form it does load my custom form when we want to create a new contact. So the form does load for a new contact. The following is a code snippet that I have been playing with all day and I was wondering if anyone out there knows how to properly replace the contacts form with a custom form just for the opening and viewing and existing contact? void __stdcall CConnect::OnNewInspector(IDispatch * /*Outlook::_Inspector**/ Ctrl) { try { CComQIPtrOutlook::_Inspector pInspector(Ctrl); IDispatchPtr spDisp = pInspector-GetCurrentItem(); Outlook::_ContactItemPtr spContactItem = spDisp; if(spContactItem != NULL) { bstr_t btName(_T("MAPI")); CComVariant myFolder(DISP_E_PARAMNOTFOUND, VT_ERROR); Outlook::_ApplicationPtr spApp = pInspector-GetApplication(); Outlook::_NameSpacePtr spNameSpace = spApp-GetNamespace(btName); Outlook::MAPIFolderPtr spContacts; Outlook::OlDefaultFolders enumODF = Outlook: ![]() spContacts = spNameSpace-GetDefaultFolder(enumODF); _bstr_t btCustomFormLocation(_T("C:\\MyCustomForms\\Outloo kForm\\MyContact.oft")); Outlook::_ContactItemPtr spCustomContactItem = spApp-CreateItemFromTemplate(btCustomFormLocation, myFolder); Outlook::OlInspectorClose oic; CComVariant varContacts(spContacts); _bstr_t btFormDescription(_T("IPM.Contact.MyContact")); Outlook::OlFormRegistry ofr = Outlook: ![]() Outlook::FormDescriptionPtr spCustomFormDescription = spCustomContactItem-GetFormDescription(); spCustomFormDescription-PutName(btFormDescription); spCustomFormDescription-PublishForm(Outlook: ![]() _variant_t(spContacts, false)); Outlook::_ItemsPtr spItems = spContacts-GetItems(); //Outlook::OlInspectorClose oic; long ItemCount = spItems-GetCount(); int changes =0; oic = Outlook: ![]() for(int n = 1; n = ItemCount; ++n) { CComVariant nItem(n); CComQIPtr Outlook::_ContactItem spItem = spItems-Item(nItem); if(spItem == NULL) continue; //IPM.DistList _bstr_t curMsgClass = spItem-GetMessageClass(); TString curMsgClassStr = (const TCHAR*)curMsgClass; TString oldMsgClassStr = ADDIN_OLDMSGCLASS; if(curMsgClassStr.compare(oldMsgClassStr) ==0) { spItem-PutMessageClass(_bstr_t(ADDIN_NEWMSGCLASS)); spItem-Save(); Outlook::_ContactItemPtr spNewContactItem = spItem-Copy(); spNewContactItem-Close(oic); spItem-Delete(); changes++; } } } } catch(...) { } } |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Emailing a contact vCard with custom form loses all custom info | Kim | Outlook - Using Contacts | 7 | April 27th 06 12:21 AM |
Adding an Outlook 2003 calendar event from a web page | bb98 | Outlook - Calandaring | 1 | April 14th 06 09:14 PM |
Cannot programmatically open custom message in custom form | ms | Outlook - Using Forms | 1 | January 20th 06 03:01 PM |
How to handling Custom Form Control Event in VB Com Add-In? | Raphaël ZHOU \(Jadiam\) | Outlook - Using Forms | 1 | January 11th 06 07:31 AM |
NewInspector Event and "No Such Interface Supported" | jim | Add-ins for Outlook | 0 | January 10th 06 03:22 AM |