A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Adding/Using a custom form during the NewInspector event



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old July 11th 06, 11:41 PM posted to microsoft.public.outlook.program_addins
Tom at GSD
external usenet poster
 
Posts: 84
Default Adding/Using a custom form during the NewInspector event

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:lFolderContacts;
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:lFolderRegistry;
Outlook::FormDescriptionPtr spCustomFormDescription =
spCustomContactItem-GetFormDescription();

spCustomFormDescription-PutName(btFormDescription);
spCustomFormDescription-PublishForm(Outlook:lFolderRegistry,
_variant_t(spContacts, false));

Outlook::_ItemsPtr spItems = spContacts-GetItems();

//Outlook::OlInspectorClose oic;

long ItemCount = spItems-GetCount();

int changes =0;
oic = Outlook:lSave;

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 08:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.