Move event between stores

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

Move event between stores
 
John Peterson




Posts: 21
Joined: 2016-07-17
I am creating an add-in for outlook where we create a store and will need to obtain the email contents/attachments when said message is "moved" from the users mailbox to the newly created store and its folders.

I have looked around the forums to see where the move events can be found. I found several that mention using the connecto method but i keep getting an error on _itemEvents.ConnectTo(root, true);

Am i missing something?


"Object reference not set to an instance of an object."

private ADXOutlookItemEvents _itemEvents;

Outlook.NameSpace ns = OutlookApp.GetNamespace("MAPI");
Outlook.MAPIFolder folder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder root = folder.Parent as Outlook.MAPIFolder;
_itemEvents.ConnectTo(root, true);
Posted 12 Mar, 2020 12:54:02 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello John,

Add an Outlook Items (not Item!) Events class to your project and use its BeforeItemMove method to handle the Folder.BeforeItemMove event of the Outlook object model; see https://docs.microsoft.com/en-us/office/vba/api/outlook.folder.beforeitemmove. Also, check section Step #13 ?Â?Ð?ã Handling Events of the Outlook Items Object; see the PDF file in the folder {Add-in Express}\Docs on your development PC or https://www.add-in-express.com/docs/net-outlook-addins.php.


John Peterson writes:
_itemEvents.ConnectTo(root, true);


_itemEvents should be initialized = new ADXOutlookItemEvents(this).


Andrei Smolin
Add-in Express Team Leader
Posted 13 Mar, 2020 01:26:06 Top
L Thrower




Posts: 21
Joined: 2016-07-17
Andrei,

when I try to initialize itemsEvents
(private ADXOutlookItemsEvents _itemsEvents = new ADXOutlookItemEvents(this);)

I get the following error. I must be overlooking something

"cannot create an instance of the abstract class"
Posted 13 Mar, 2020 14:31:29 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello L,

Check section Step #13 ?Â?Ð?ã Handling Events of the Outlook Items Object; see the PDF file in the folder {Add-in Express}\Docs on your development PC.


Andrei Smolin
Add-in Express Team Leader
Posted 16 Mar, 2020 01:37:35 Top
L Thrower




Posts: 21
Joined: 2016-07-17
Thank you, Andrei.
I will try to reinstall as I do not see the outlook events class under installed templates.
Posted 16 Mar, 2020 09:00:55 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
This is the Add New Item dialog, not the New Project dialog. Also, check whether Add-in Express is listed on the About dialog window; see Help | About in your Visual Studio IDE.


Andrei Smolin
Add-in Express Team Leader
Posted 16 Mar, 2020 09:05:32 Top
L Thrower




Posts: 21
Joined: 2016-07-17
Andrei,
Thank you for your information. I have been able to capture the event for all stores and folders.
This being said I noticed occasionally, the BeforeItemMove event does not get called. what could cause this event to get skipped?
Posted 18 Mar, 2020 13:34:09 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello L,

This may relate to the Outlook version and store type(s) used.

What Outlook build are you using? Please send me the complete version information shown to the right of the About Outlook button (do not click it!); find the button at File | Office Account.

Does the event not fire on a specific store type? Primary or secondary Exchange mail box? Imap folder? PST?

I'd recommend that you google for a suggestion.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Mar, 2020 16:34:59 Top
L Thrower




Posts: 21
Joined: 2016-07-17
Thank you for the quick reply.

Outlook version: Version 2002 (Build 12527.20278 Click-to-Run)

It doesn't seem to be with any specific store and we are not supporting exchange at the moment.
Looks like all of the email accounts on my machine are IMAP. This issue is seldom.

Are there any developer tools I can use to watch what outlook is doing?

I will continue to search online. I appreciate all of your guidance
Posted 18 Mar, 2020 17:08:15 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello L,

Check whether the issue persists if you turn off all other COM add-ins.

Also, do you release all COM objects in your code? Does the issue persist if you comment out all your functional code except for the event handler of the BeforeItemMove event that prints a debug message? If so, please send me a test project reproducing the issue.


Andrei Smolin
Add-in Express Team Leader
Posted 19 Mar, 2020 05:40:02 Top