AddItem event.

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

AddItem event.
 
Tony Hunt




Posts: 13
Joined: 2011-06-10
I have compiled the sample code in adxOLFolderItemsEvents and it seems to work except the additem event appears to trigger ONLY for the inbox, not for any sub-folders.

Is this correct?

If so, how do I detect incoming emails going to subfolders.

Best Wishes

Tony Hunt
Posted 09 Sep, 2011 06:49:06 Top
Andrei Smolin


Add-in Express team


Posts: 14980
Joined: 2006-05-11
Hi Tony,

Are you talking about the sample labelled "How to connect to ItemAdd, ItemChange, and ItemRemove events in Outlook?" at http://www.add-in-express.com/support/addin-delphi.php#events?

If so, then the idea is to intercept events (ItemAdd, ItemChange, and ItemRemove) of the Items collection of a given folder. You can modify the procedure below to meet your needs.

procedure TAddInModule.ConnectToFolderByIndex(const AIndex: Integer);
var
  DefFolder: OlDefaultFolders;
begin
  case AIndex of
    1: DefFolder := olFolderDeletedItems;
    2: DefFolder := olFolderDrafts;
    3: DefFolder := olFolderInbox;
    4: DefFolder := olFolderOutbox;
    5: DefFolder := olFolderSentMail;
    6: DefFolder := olFolderContacts;
    7: DefFolder := olFolderTasks;
    8: DefFolder := olFolderCalendar;
  else
    DefFolder := olFolderInbox;
  end;
  FFolderItems.ConnectTo(OutlookApp.GetNamespace('MAPI').GetDefaultFolder(DefFolder));
end;


Does it help?

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Sep, 2011 07:39:23 Top
Tony Hunt




Posts: 13
Joined: 2011-06-10
I am using the demo app. adxOLFolderItemsEvents as a basis for my app.

The procedure TAddInModule.ConnectToFolderByIndex(const AIndex: Integer); is exactly as you say and during initialising the value for AIndex is 3, as I expect.

Messages coming in to the root of the InBox are raising the event as I expect but those being sent into lower folders Inbox/Tony for example, are not raising the event. These messages are being redirected using the Outlook Rules & Alerts functions.

Hope this clarifies the problem I am seeing.

Best Wishes

Tony Hunt
Posted 09 Sep, 2011 08:52:26 Top
Andrei Smolin


Add-in Express team


Posts: 14980
Joined: 2006-05-11
Hi Tony,

You need to intercept the ItemAdd event of those folders, too. And that means modifying that procedure. Currently, you get Inbox in this code:

OutlookApp.GetNamespace('MAPI').GetDefaultFolder(DefFolder)


Now you need to get every MAPIFolder listed in the Folders collection of the MAPIFolder object representing Inbox, get the Items collection via MAPIFolder.Items, and connect to events of the Items collection.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Sep, 2011 09:06:58 Top
Tony Hunt




Posts: 13
Joined: 2011-06-10
Hi Andrei,
Thanks for the quick response.

Does one of your sample apps demonstrate how to do this?

I'm sure I'm not the first who wants to do this.

Best Wishes

Tony Hunt
Posted 09 Sep, 2011 09:28:36 Top
Andrei Smolin


Add-in Express team


Posts: 14980
Joined: 2006-05-11
Hi Tony,

That sample demonstrates how to connect to these events for a specific folder(s). You need to modify it to access the folders below the Inbox. I described the idea in my previos post.

Oh, look into the sample labelled "How to scan Outlook folders using Delphi" at http://www.add-in-express.com/support/addin-delphi.php.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Sep, 2011 09:45:58 Top
Tony Hunt




Posts: 13
Joined: 2011-06-10
Hi Andrei,

Thank you for your assistance.
I have looked into the sample labelled "How to scan Outlook folders using Delphi" at http://www.add-in-express.com/support/addin-delphi.php.

Unfortunately my programming skills are unable to add an event into each folder.

Luckily I found this VERY OLD thread from 2004.
http://www.add-in-express.com/forum/read.php?FID=1&TID=73&MID=297#message297
this contains a reference to
http://www.add-in-express.com/projects/ol_move_items.zip

This provides me with enough clues to do everything I need.

Best Wishes

Tony Hunt
Posted 09 Sep, 2011 22:01:07 Top
Andrei Smolin


Add-in Express team


Posts: 14980
Joined: 2006-05-11
Oh, I see.

Thank you for letting me know that the issue is solved.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Sep, 2011 02:49:47 Top