Event not firing properly

N

Neetu

We are adding folder structure ( 1 parent and 2-3 child folders). on addining
or deleting of any mail items from these folders we are connecting to
database and updating a table.
items.ItemAdd and items.ItemRemove events are beign trapped for these
folder.
After one Insertion of row inside table, items.ItemAdd Events is not firing.
explorerObject.SelectionChange is firing each time we click over a mail item.

If we removes our code to insert into database, items.ItemAdd gets fire.
we also tried to insert into database using thread. however that also not
working.

Kindly , if we can find some techincal reason and solution for our issue, it
would solve our issue.

Thanks In advance.
Neetu
 
K

Ken Slovak - [MVP - Outlook]

Are the object variables and the event handler still in scope? What language
are you using? Is it possible that you aren't declaring the objects at a
high enough scope to keep them from being garbage collected?

Please provide more information as to Outlook version, language and show
some of the code you're using.
 
N

Neetu

We are using C#, Outlook Shared addin for office 2007,VS.net 2005.

on OnStartupComplete, the folders are created (if not exist inside outlook's
folder view) from querying a database through webservice for a single data
(sDate).

folder structure will be like this:

PARENT
INBOX
SENT ITEMS
OURFolder
sDate
sReceived
sSent


after creating the folders, we use

MAPIFolder MFReceived =
MFParent.Folders[sMAIN].Folders[sDate].Folders[sReceived];MAPIFolder MFSent =
MFParent.Folders[sMAIN].Folders[sDate].Folders[sSent];
MFReceived.Items.ItemAdd += new ItemsEvents_ItemAddEventHandler(Item_ItemAdd);
MFReceived.Items.ItemRemove += new
ItemsEvents_ItemRemoveEventHandler(Item_ItemRemove);
MFSent.Items.ItemAdd += new ItemsEvents_ItemAddEventHandler(Item_ItemAdd);
MFSent.Items.ItemRemove += new
ItemsEvents_ItemRemoveEventHandler(Item_ItemRemove);

to attach the events.

Events get fired and we are able to add row inside our database table for
1st time.

but after first time, these two events are not triggered.
 
K

Ken Slovak - [MVP - Outlook]

Is MAPIFolder MFReceived declared at the class level or inside a procedure
such as OnStartupComplete()? If it's in OnStartupComplete() then as soon as
that procedure ends the object goes out of scope and eventually will be
garbage collected. To keep something like that event live you must declare
the MFReceived object at class level so it doesn't get garbage collected.
 
N

Neetu

Issued has been resolved . Thanks for Information.

we are Using VSTO SE , c#, VS.NET 2005 for outlookaddin. we are using
CustomTaskPanes with usercontrols.
Our requirement -> on click of our folder one task pane should open in
complete region of explorer and instector.
public void Explorer_SelectionChange()
{
if (selectedFolder.Name.ToUpper().Equals("TUBETRAK"))
{
LoginUI = new UserControl();

Outlook.Explorer _ActiveExplorer =
applicationObject.ActiveExplorer();
LoginCustomTaskPane = this.CustomTaskPanes.Add(LoginUI,
"OurTaskPane", _ActiveExplorer);

LoginCustomTaskPane.Visible = true;
}
}

A new Task pane is creating. but explorer and inspector are visible and our
taskpane is visible in right of these 2 , in small region.
we want to display whole task pane as normal URL for folder in outlook.


Kindly help.



Neetu said:
We are using C#, Outlook Shared addin for office 2007,VS.net 2005.

on OnStartupComplete, the folders are created (if not exist inside outlook's
folder view) from querying a database through webservice for a single data
(sDate).

folder structure will be like this:

PARENT
INBOX
SENT ITEMS
OURFolder
sDate
sReceived
sSent


after creating the folders, we use

MAPIFolder MFReceived =
MFParent.Folders[sMAIN].Folders[sDate].Folders[sReceived];MAPIFolder MFSent =
MFParent.Folders[sMAIN].Folders[sDate].Folders[sSent];
MFReceived.Items.ItemAdd += new ItemsEvents_ItemAddEventHandler(Item_ItemAdd);
MFReceived.Items.ItemRemove += new
ItemsEvents_ItemRemoveEventHandler(Item_ItemRemove);
MFSent.Items.ItemAdd += new ItemsEvents_ItemAddEventHandler(Item_ItemAdd);
MFSent.Items.ItemRemove += new
ItemsEvents_ItemRemoveEventHandler(Item_ItemRemove);

to attach the events.

Events get fired and we are able to add row inside our database table for
1st time.

but after first time, these two events are not triggered.


Ken Slovak - said:
Are the object variables and the event handler still in scope? What language
are you using? Is it possible that you aren't declaring the objects at a
high enough scope to keep them from being garbage collected?

Please provide more information as to Outlook version, language and show
some of the code you're using.
 
K

Ken Slovak - [MVP - Outlook]

A CTP is an additional pane that gets displayed in the Explorer or
Inspector, just as the Help pane would be displayed. It doesn't replace the
normal folder view of an Explorer.

To do that you have to design your UI as a Web page and set up the folder
home page to display your Web page, which can be a local HTML file, it
doesn't have to be on the Web. Use the MAPIFolder.WebViewURL, .WebViewOn and
the hidden .WebViewAllowNavigation properties to set that up.

There is no way to do that for an open item (Inspector) unless you proxy the
opening of an item (trapped in NewInspector()) and display a form or
something instead of the Inspector.

You will have to re-think your requirements.
 
N

Neetu

Hello Ken,

how to create a proxy of item open in newinspector opening?
do we need to trap ' new
Outlook.InspectorsEvents_NewInspectorEventHandler' event ?how to display a
form instead of inspector.


Please elaborate this point.
 
K

Ken Slovak - [MVP - Outlook]

You'd use that event handler to get the new Inspector. You'd then close the
Inspector after getting whatever properties you wanted from the
Inspector.CurrentItem. Then you'd use those properties to fill in whatever
form you wanted.

Depending on the Outlook version the CurrentItem available in NewInspector
can be a weak object reference, not a strong reference. That means that not
all properties of the item or the Inspector are necessarily available in
NewInspector(). Usually you can see if they are but you must be prepared to
find that some or many properties aren't available until the first
Inspector.Activate() event of that Inspector.

As a general rule of thumb I never assume that anything is available for
Inspector.CurrentItem except for item.Class and item.MessageClass.
 
N

Neetu

Hi ken,

new Insepctor event cannot be trapped as we need our winform on the same
explorer window. we used custom task pane to show our usecontrol.
we tried to hide currentview of folder (ourfolder) . however it is not
possible using c#.

we can turn off reading pane for folder.we can customized the currentview of
folder with mininum no of fields as 1. still current view will be visible.
also using custom task pane usercontrol shows as browse popup which can be
dragged and resize and close.

is there any way to hide currentveiw?
 
K

Ken Slovak - [MVP - Outlook]

Not that I know of. I already listed all your options. If none of those are
suitable then you must re-design your spec to do what's possible and not
what's desired.
 
N

Neetu

Hi ken,
We planned to go for web page. win form or custom task pane doesn't work
properly for our current requirement.

Thanks for guidance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top