Working with MAPIStoreAccessor gives problems

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

Working with MAPIStoreAccessor gives problems
Outlook stops sending e-mails 
Bargholz Thomas




Posts: 236
Joined: 2006-12-18
Hi Andrei,
It works! Brilliant! I would never have guessed that. Thank you so much! :D
Regards
Thomas
Posted 21 Jan, 2010 11:17:03 Top
Bargholz Thomas




Posts: 236
Joined: 2006-12-18
Hi,
we still experience problems with the MAPIStoreAccessor event handling.
The code works perfectly for sending e-mails and adding documents.
But when the e-mail is a meeting request, an answer or cancellation to a meeting request, the request/reply just stay in the outbox.
What could cause this? I release the folder, the item and the namespace, which are the only COM data I handle.
Here is my code:

{
string id = e.EntryId.ToString();
string storeid = e.StoreId.ToString();
string parentid = e.ParentId.ToString();

Outlook.NameSpace ns = null;
Outlook.MAPIFolder parent = null;
Outlook.MailItem mail = null;
Outlook.DocumentItem doc = null;
object item = null;
bool handleDrop = false;
try
{
ns = OutlookApp.GetNamespace("MAPI");
item = ns.GetItemFromID(id, storeid);

if (item == null)
return;

// check for mails
if (item is Outlook.MailItem)
{
mail = (Outlook.MailItem)item;
parent = ns.GetFolderFromID(parentid, storeid);

if (parent != null)
{
if ((parent.Description != null) && (parent.Description.StartsWith(PROP_FOLDER_ID)))
handleDrop = true;
}
}
// check for documents
else if (item is Outlook.DocumentItem)
{
doc = (Outlook.DocumentItem)item;
parent = ns.GetFolderFromID(parentid, storeid);

if (parent != null)
{
if ((parent.Description != null) && (parent.Description.StartsWith(PROP_FOLDER_ID)))
handleDrop = true;
}
}

if (handleDrop)
{
long folderid = this.GetFolderId(parent.Description);
if (folderid > 0)
{
// code to handle item storage
}
}
}
finally
{
if (parent != null)
Marshal.ReleaseComObject(parent);

if (item != null)
Marshal.ReleaseComObject(item);

if (ns != null)
Marshal.ReleaseComObject(ns);
}

}


Regards
Thomas
Posted 25 Jan, 2010 04:49:37 Top
Bargholz Thomas




Posts: 236
Joined: 2006-12-18
I have also sent a new version of my demo project to the support e-mail, whith the code that works for MailItem and DocumentItem, but fails when sending out appointments, replying to them or cancelling them.
Regards
Thomas
Posted 25 Jan, 2010 06:23:44 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hi Thomas,

In ProcessMAPIEvent, I'd check if e.Parent points to Outbox and return before doing any checks of the item.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 25 Jan, 2010 09:23:32 Top
Bargholz Thomas




Posts: 236
Joined: 2006-12-18
Hi Andrei,
I've rewritten the code so that if it's the Outbox, I do nothing at all. and I only get the item if it's in a folder I monitor.
This seems to run smoothly. Thanks for your help 8)
Regards
Thomas
Posted 26 Jan, 2010 02:52:48 Top