|
wehbi
Posts: 76
Joined: 2013-10-31
|
Dear ADX-Team,
to use the ItemsEventClass we have to hook the event class like this:
OutlookItemsEvent.ConnectTo(ADXOlDefaultFolders.olFolderInbox, true);
Am I right, the event class will not work for the inbox sub folder?
Thanks and regards,
Birger |
|
Posted 14 Aug, 2017 04:25:16
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hello Birger,
Yes, you are right. But the following call of the ConnectTo method will handle sub-folders:
OutlookItemsEvent.ConnectTo(ADXOlDefaultFolders.olFolderInbox, true, true);
|
|
Posted 14 Aug, 2017 06:25:35
|
|
Top
|
|
wehbi
Posts: 76
Joined: 2013-10-31
|
Hi Dmitry,
thanks a lot, I didn't recognize the overload.
Regards,
Birger |
|
Posted 14 Aug, 2017 06:45:24
|
|
Top
|
|
wehbi
Posts: 76
Joined: 2013-10-31
|
It's confusing. Sometimes the ItemAdd event is fired when d'n'd a mail to another folder on different exchange server, sometimes the BeforeItemMove and ItemChanged event is fired. Why is not always the ItemAdd event fired?
Thanks an regards,
Birger |
|
Posted 14 Aug, 2017 08:19:14
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hello Birger,
Could you please send me your project (or even better a small demo project with the same behavior) for testing? I will try to find out the cause. |
|
Posted 14 Aug, 2017 10:22:02
|
|
Top
|
|
wehbi
Posts: 76
Joined: 2013-10-31
|
Hi Dmitry,
I will try to explain it first.
When I hook the event class like this:
private void AddinModule_AddinStartupComplete(object sender, EventArgs e)
{
// items event class
OutlookItemsEvent = new OutlookItemsEventsClass(this);
OutlookItemsEvent.ConnectTo(ADXOlDefaultFolders.olFolderInbox, true, true);
}
Only one of three mailboxes will fire the ItemAdd event. Do I have to hook the event class in a different way, that all mail accounts will fire the event when I drop mails from one incoming mail folder to another?
Thanks and regards,
Birger |
|
Posted 15 Aug, 2017 02:10:26
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
|
Posted 15 Aug, 2017 05:22:33
|
|
Top
|
|
wehbi
Posts: 76
Joined: 2013-10-31
|
Hi Dmitry,
thanks a lot.
I solved it like this:
private void AddinModule_AddinStartupComplete(object sender, EventArgs e)
{
// items event class
Outlook.NameSpace olNs = null;
Outlook.Stores olStores = null;
try
{
olNs = AddinModule.CurrentInstance.OutlookApp.Session;
olStores = olNs.Stores;
for (int i = 1; i < olStores.Count; i++)
{
Outlook.Store olStore = olStores[i];
if (olStore != null)
{
Outlook.MAPIFolder olFolder = olStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
if (olFolder != null)
{
var olItemEvents = new OutlookItemsEventsClass(this);
olItemEvents.ConnectTo(olFolder, true, true);
if (OutlookItemsEventList == null) OutlookItemsEventList = new List<OutlookItemsEventsClass>();
OutlookItemsEventList.Add(olItemEvents);
Marshal.ReleaseComObject(olFolder);
}
Marshal.ReleaseComObject(olStore);
}
}
}
catch (Exception exception)
{
log.Warn(exception, "Hook Outlook Event Item Class Exception");
}
finally
{
if (olStores != null) Marshal.ReleaseComObject(olStores);
if (olNs != null) Marshal.ReleaseComObject(olNs);
}
}
and
private void adxOutlookEvents_Quit(object sender, EventArgs e)
{
foreach (var olItemsEventClass in OutlookItemsEventList)
{
if (olItemsEventClass != null)
{
olItemsEventClass.RemoveConnection();
olItemsEventClass.Dispose();
}
}
}
Regards,
Birger |
|
Posted 15 Aug, 2017 07:55:20
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hello Birger,
Thank you for keeping us informed and good luck with your project! |
|
Posted 15 Aug, 2017 10:01:39
|
|
Top
|
|