"public override void ProcessItemAdd(object item)" is not working

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

"public override void ProcessItemAdd(object item)" is not working
"public override void ProcessItemAdd(object item)" is not working formy ,cutom folders 
Ashish Sinha




Posts: 51
Joined: 2011-03-29
Hi all,

I try to grab the mail items which add in my any outlook folders(either outlook folders or my
custom folders). but this event never get fired .see the following code snippet.


Microsoft.Office.Interop.Outlook.MAPIFolder fol_acnt;
Microsoft.Office.Interop.Outlook.MAPIFolder fol;
int acctcnts = ((Microsoft.Office.Interop.Outlook.Store)_Outlook.ns.GetStoreFromID(_Outlook.ns.Application.Session.DefaultStore.StoreID)).Session.Folders.Count;

for (int folacnt = 1; folacnt < acctcnts; folacnt++)
{
fol_acnt = ((Microsoft.Office.Interop.Outlook.Store)_Outlook.ns.GetStoreFromID(_Outlook.ns.Application.Session.DefaultStore.StoreID)).Session.Folders[folacnt];

// MessageBox.Show(fol_acnt.Folders[folcn].Name.ToString());

for (int folcn = 1; folcn < fol_acnt.Folders.Count; folcn++)
{


evnt.ConnectTo((Microsoft.Office.Interop.Outlook.MAPIFolder)fol_acnt.Folders[folcn],true );

MessageBox.Show(fol_acnt.Folders[folcn].Name.ToString());
}
}


Please help me.

Thanks,
Ashish.
Posted 03 Apr, 2011 01:02:49 Top
Ashish Sinha




Posts: 51
Joined: 2011-03-29
Please reply me. :)
Posted 04 Apr, 2011 04:53:08 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Ashish,

Did you try to debug? Is the following line of code reachable?

evnt.ConnectTo((Microsoft.Office.Interop.Outlook.MAPIFolder)fol_acnt.Folders[folcn],true );


1. Please note that the GetStoreFromID return an instance of the Store class in Outlook (not MAPIFolder).
2. You need to connect the events class to the root folder of the store (see the GetRootFolder function of the Store class in Outlook).
3. Where do you instantiate the evnt object? Do you create a separate instance of the events class for each folder?

BTW What version and build number of Add-in Express do you use?
.NET, Extended MAPI, Windows Phone & RT
Posted 04 Apr, 2011 07:02:33 Top
Ashish Sinha




Posts: 51
Joined: 2011-03-29
Hi Eugene,

Thanks for yor reply.

I am using Add-in-Express API (V. 603-b3052-vs-pre_1) Add-in Express 2010 for Microsoft Office and .NET, Premium.

Please note that the GetStoreFromID return an instance of the Store class in Outlook (not MAPIFolder).

--- I have 5 accouns in my Outlook 2010 with different names , and I want to grab any
new mails comes or remove from any folder of any account of my outlook 2010 , requirement
is like this.that why I am fetching account from account collection through storeid like following :

fol_acnt = ((Microsoft.Office.Interop.Outlook.Store)_Outlook.ns.GetStoreFromID(_Outlook.ns.Application.Session.DefaultStore.StoreID)).Session.Folders[folacnt];

Then after I Iterate each foldr of each account and bound to "eventitems" class :
for (int folcn = 1; folcn < fol_acnt.Folders.Count; folcn++)
{
evnt.ConnectTo((Microsoft.Office.Interop.Outlook.MAPIFolder)fol_acnt.Folders[folcn],true );
MessageBox.Show(fol_acnt.Folders[folcn].Name.ToString());
}
}

So, if any mail come either it as new item or copied from any other folders event should be fired .


I am using one instance of "Outlookitemsevents" class for each folder of each account.

Question:


If I use root folder then "evens" will fire for every folder of the its root folder.


plaese help me.

Thanks,
Ashish Sinha.
Posted 04 Apr, 2011 09:02:36 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Ashish,

Please note that you need to use a separate instance of the AddinExpress.MSO.ADXOutlookItemsEvents for each folder.

To get assistance with host applications objects, their properties, and methods as well as help info, use the Object Browser. Go to the VBA environment (in the host application, choose menu Tools | Macro | Visual Basic Editor or just press {Alt+F11}), press {F2}, select the host application in the topmost combo and/or specify a search string in the search combo. Select a class /property /method and press {F1} to get the help topic that relates to the object.
.NET, Extended MAPI, Windows Phone & RT
Posted 04 Apr, 2011 09:38:15 Top
Ashish Sinha




Posts: 51
Joined: 2011-03-29
Hi Eugene,

Thanks for your reply.

But I tried for followings folders with single instance of the "AddinExpress.MSO.ADXOutlookItemsEvents" class and it works:

1)"draft"
2)Outbox.
3)Sent Item.

It would be great if you provide me proper solution with any sample project.


Thanks,
Ashish Sinha.
Posted 05 Apr, 2011 00:42:27 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Ashish,

Please take a look at the How to determine if an item was added to, changed in, or removed from a given Outlook folder(s) sample add-in project in the HOWTO section of our web site. Does it work for you?
.NET, Extended MAPI, Windows Phone & RT
Posted 05 Apr, 2011 05:08:20 Top
Ashish Sinha




Posts: 51
Joined: 2011-03-29
Hi Eugene,

This link is not being opened from my side :

"How to determine if an item was added to, changed in, or removed from a given Outlook folder(s)"

:)


Thanks,
Ashish
Posted 05 Apr, 2011 06:46:13 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Ashish,

You can find the mentioned sample add-in project on the page which is opened in the browser followed by the link. Anyway, please use this direct link instead.
.NET, Extended MAPI, Windows Phone & RT
Posted 05 Apr, 2011 06:50:58 Top
Ashish Sinha




Posts: 51
Joined: 2011-03-29
Hi,

Thanks for your reply.


This example only worked for first number of Account' Folder ('Deleted,Inbox' e.t.c) ,in sequence. since I have three accounts,
say :Ashish_softGmail.com,ashish_rediffmail.com,ashish_yahoo.com.


I need to capture the events "ProcessItemAdd" and "ProcessItemRemove" for all "Deleted" Folders from each accounts,Ashish_softGmail.com,ashish_rediffmail.com,ashish_yahoo.com.

As I am indexing the entire mails item from each accounts, so whenever new mail comes or
remove from/to any folder ,these event should call and I could update my database accordingly.

Please help me .

Thanks,
Ashish.
Posted 05 Apr, 2011 12:45:44 Top