Replacing Embeded Forms with click on one form.

Add-in Express™ Support Service
That's what is more important than anything else

Replacing Embeded Forms with click on one form.
Embeded Form Adx- Outlook extension 
Eugene Starostin


ADX Team
Add-in Express team


Posts: 430
Joined: 2004-04-05
Vivek,

Do not use the constructor of the add-in module to access Outlook objects. So, call CreateCRMTodayFolders in the AddinStartupComplete event handler of the add-in module.
Posted 30 May, 2006 05:01:06 Top
Vivek Jain




Posts: 19
Joined: 2006-05-26
HI Eugene,

Unfortunalety It is not showing the AddinStartupComplete event in the MY VS.Net IDE. when I select the AddinModule Class it dose not show any such events in method list box. I refered your PDF file as well but not able to undersatnd that how i can i achieve this. Can you please send me the sample code that what i need to do to access AddInModule Events so that i can place my code there.


I have one more issue left and Fedor told me to reply today.
The Second issue is :

I want to change the explorer view for this newly created folder only not the all having the same type which this folder have. I mean if i create a folder of mail type and i place form manager properties as


I will Keep in mind to not upload my code in your forums unless you ask to do so.

Thanks In advance.


Best Regards,
Vivek Jain
Posted 30 May, 2006 05:35:01 Top
Eugene Starostin


ADX Team
Add-in Express team


Posts: 430
Joined: 2004-04-05
Vivek,

1. AddinStartupComplete. Please have a look at page 111 of Add-in Express Class Reference.

2. To connect your form to one folder you can use the FolderName property of the corresponding item of Outlook Forms Manager.
Posted 30 May, 2006 06:54:41 Top
Vivek Jain




Posts: 19
Joined: 2006-05-26
HI Eugene,

Thanks for your Supoprt!!

I just left with one issue as of now to create my proof of concept which i have also spoken to Fedor.

The issue is

I want to change the explorer view for the newly created folder ( Custom Folder) only not the all having the same type which this folder have. I mean if i create a folder of mail type and i place form manager properties as

ItemType mail
Folder Class "AnyformClass name"
Foldername "Newly Created Folder only"

Then It should apply only the folder not all but in my case it is applied to all even after i mentioned the folder name.....


Fedor Replied : will create a sample that will demonstrate how to show a separate form for a folder when for other folder of this type there will be another form showing. Wait for tomorrow, please.


Please sort it out this issue as when i replace the exploere view of one folder every folder having the same view does get change.

Thanks In advance ...

Best Regards,
Vivek Jain
Posted 30 May, 2006 10:15:53 Top
Vivek Jain




Posts: 19
Joined: 2006-05-26
HI Eugene,

It will be a great help if we can sort it out Today itself.


Best Regards,
Vivek Jain
Posted 30 May, 2006 10:23:19 Top
Fedor Shihantsov


Add-in Express team


Posts: 1188
Joined: 2005-01-11
Hello Vivek,

Here is the sample

http://www.add-in-express.com/files/projects_pub/adxol-fm-vs2005-ShowSpecialForm.zip

This sample demonstrate how to show a separate form for a folder when for other folder of this type there will be another form showing.

The ADXOlFormsManager has two item.
The first one for the Inbox folder (InboxItem).
The second one for other mail folders (MailItem).
In ADXOlFormsManager.OnInitialize handler the full folder name for inbox folder is set.

This sample is based on the fact that ADXOlFormsManager processes items in ascending order.
If appropriate item was found then other items are ignored.
In result when we select the Inbox folder ADXOlFormsManager creates a form of the first item (InboxItem).
For other mail folders it uses the second item (MailItem).

Posted 31 May, 2006 08:31:36 Top
Vivek Jain




Posts: 19
Joined: 2006-05-26
Hi Fedor,

Thanks for your Reply !!

I do have some confusion about this.

1) First of all i do have a folowing hierachy of folders which will be created at runtime with Add-in Express by using Outlook.createFolder Method.

SessionDefaultFolder -> MYCustomFolderRoot(Root for my OtherCustomFolder's)-> MyCustomFolderChild (On which i have to apply my custom Form)

So no inbox folder in this case and inbox folder should use the view orginally it has like showing mails..

2) In my case I just have to replace the view of my custom folder only rest should use the default one not the other form as per your sample.

3)Your sample shows formmanager has two items so in my case as well I have to place two items if yes then what should be the folderclassname for the second item as i want rest of the folder to use default view not the other custom form as in your sample.

4)What statement in Add-in Intialize event i should write to apply my form to the folder i described above. I hope some general expression can help me out.

Note: - I Have to bind the FolderName to the FormManagerItem which will be created in Add-in StartUp complete Event. So, Can I write the code to Bind Formanager Foldername Property To this folder in Add-Intialize event which will actually be created in Add-In startUpComplete Event.
Folder Create means to create a folder under the Seesion Root Folder by writing the code in Ad-in StartUp complete Event.



One more thing how can i update the latest version of Add-in Outlook. As i try to download it from Download section but it says i have to uninstall the previous version first. Is this needs to be done and may it possible for crashing existing app. Please suggest me the right way.

By the way i have got the tremendous support from you guys. Thanks very much for this.

Best Regards,

Vivek Jain
Posted 01 Jun, 2006 07:23:37 Top
Fedor Shihantsov


Add-in Express team


Posts: 1188
Joined: 2005-01-11
Hi Vivek,

1)
In your case one item is enough.
After creating a folder, set the FolderName property in your ADXOlFormsCollectionItem like in the adxOlFormsManager1_OnInitialize event. As a result your item should have the following properties set:
FormClassName, ExplorerLayout, FolderName. Other properties are default.

2)
If you are upgrading from the older version of ADX Extensions for Outlook to the new one, you should uninstall the older version.
After installing the new version you are to rebuild your old addins that use the ADX Extensions.

P.S.
If in the sample above you add the following code to the ADXOlFormsManager.ADXBeforeFolderSwitch handler,
then ADXOlFormsManager will stop showing the form for the Inbox folder


private void adxOlFormsManager1_ADXBeforeFolderSwitch(object explorerObj, AddinExpress.OL.ADXOlFormsCollectionItem SrcItem, object SrcFolder, AddinExpress.OL.ADXOlFormsCollectionItem DstItem, object DstFolder)
{
    Outlook.MAPIFolder DestinationFolder = DstFolder as Outlook.MAPIFolder;
    if (DestinationFolder != null)
    {
        if (DestinationFolder.Name == "Inbox")
        {
            adxOlFormsManager1.LockUpdates();
            InboxItem.Enabled = false;
            MailItem.Enabled = false;
            adxOlFormsManager1.UnlockUpdates();
        }
        else
        {
            adxOlFormsManager1.LockUpdates();
            InboxItem.Enabled = true;
            MailItem.Enabled = true;
            adxOlFormsManager1.UnlockUpdates();
        }
    }
}


Posted 01 Jun, 2006 09:45:55 Top
Vivek Jain




Posts: 19
Joined: 2006-05-26
Hi Fedor,

Thanks For your Reply..But there are some confusion about the formmanagerProperties..and add-in events. I have Three senerios let us take a look one by one

First : --- IF i can create folder(s) in Add-in Intialize event ??

As per your sample you are assigning the foldername property in Add-in Intialize event as folder exist Already. Now in my case folder dosnt exist and i need to create that so can i create the folder in add-in Intialize event?? if yes then in your sample you have written below statement to assign the foldername as inbox

InboxItem.FolderName = ParentInboxFolderObj.Name + @"\" + InboxFolderObj.Name;

so in my my case how this statement will look like. I have already mentioned the hireachy of my custom folder(s) in my previous post.
IF this approach i can use i just can simply follow your sample by just deleting the second formmanager Item (MailItem) and WithOut Writing anything in FolderBeforeSwtich Event hander as you suggested in second post.

Second : ----
Now second Approach If I can not create my folder(s) in Add-In Intilize event then I need to create them In Add-in Startupcomplete Event.
I also place a formmanager and create one item with two properties Statically assigned as
FormClassname : Someclassname
ExplorerLayoyut : WebView
and rest properties is default.

Now with this approach i can not assign FolderName in Add-in Intialize as it will be careated in later event.
So i will assign the folderName property with the foldername right after i create the folder in that later event. Now as per your sample it should work but it dosnt.

This approach works only when i assign one more propety of formmanager as
ExploereItemType : Anyitemtype.
But If i do that my all folder of the sametype have same form which i dont want.


Third :- -------

In this Approach um able to do what i want but it comes at some processing cost. this approach is

step1 :

I assign below Formmanager Propeties at design time :
ExploereItemType : Anyitemtype ( Forex. mail)
Exploerer Layout : WebView
Formclassname : Anyclassname (Forex. Myform1)

Step2 :
Create folder(s) in Add-in statupcomplete

Step3 :
Write below code in FormBeforeswitch event handler
public void adxOlFormsManager1_ADXBeforeFolderSwitch(object explorerObj, AddinExpress.OL.ADXOlFormsCollectionItem SrcItem, object SrcFolder, AddinExpress.OL.ADXOlFormsCollectionItem DstItem, object DstFolder)
{

Outlook.MAPIFolder DestinationFolder = DstFolder as Outlook.MAPIFolder;
if (DestinationFolder != null)
{
if (DestinationFolder.Name == "SuitecaseDesktop")
{
adxOlFormsManager1.LockUpdates();
adxOlFormsCollectionItem1.FolderName = "MyCustomFolder";
adxOlFormsManager1.UnlockUpdates();
}
else
{
adxOlFormsManager1.LockUpdates();
adxOlFormsCollectionItem1.Enabled = false;
adxOlFormsManager1.UnlockUpdates();
}
}
}

Now in this approach everytime the folder switches then this code will get executed. Can you suggest me some better solution and if possible send me the sample according to my needs. It will be great help.
I hope you have understand the issue in depth.

Note: - In both the scenerios ( Second and third ) i have to set
ExploereItemType Propety of formmanager intially or dynamicallly otherwise it dosnt work. So execpt First Approach on which your sample is based, i have to assign this property otherwise it will not work. I will suggest you try it urself by examining the third approach.


Thanks In advancve

Best Regards,
Vivek Jain











Posted 02 Jun, 2006 06:07:12 Top
Fedor Shihantsov


Add-in Express team


Posts: 1188
Joined: 2005-01-11
Vivek,


First : --- IF i can create folder(s) in Add-in Intialize event ??


You can create a folder in Add-in Intialize event.


in your sample you have written below statement to assign the foldername as inbox ... so in my my case how this statement will look like


Your code should create the follow string:
RootFolderName\SessionDefaultFolder\MYCustomFolderRoot\MyCustomFolderChild
I.e. the FolderName property must contain the full folder path starting from the Root Folder. Yhe code below shows all root folders.


Outlook.MAPIFolder RootFolder = null;
Outlook.NameSpace ns = null;
try
{
    ns = OutlookApp.GetNamespace("MAPI");
    for (int i=1; i<=ns.Folders.Count; i++)
    {
        try
        {
            RootFolder = ns.Folders[i];
            MessageBox.Show(RootFolder.Name); 
        }
        finally
        {
            if (RootFolder != null)
            {
                Marshal.ReleaseComObject(RootFolder);
                RootFolder = null; 
            }
        }
    }
}
finally
{
    if (ns != null)
    {
        Marshal.ReleaseComObject(ns);
    }
}  



Second :
This approach works only when i assign one more propety of formmanager as
ExploereItemType : Anyitemtype.
But If i do that my all folder of the sametype have same form which i dont want.


In my sample the ExploereItemType property is not needed because the FolderName property of InboxItem is set. I.e. theInboxItem will correspond to one particular folder (Inbox folder).


Third :- -------


I don't quite understand what you want to achieve in the third approach.

if you want to display the form for one folder only, then why do you set the FolderName property each time? Besides, as I have already mentioned, the FolderName must contain the full path to the folder.

Posted 05 Jun, 2006 10:24:38 Top