Using Redemption Data Objects and ADX

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

Using Redemption Data Objects and ADX
Outlook Mail Items created using RDOMail do not fire ADX events 
Martin Bayly




Posts: 41
Joined: 2007-10-05
Hi

ADX 3.8 1886.2005
Redemption 4.4.0.714

We're using Redemption (RDOMail) to create an Outlook mail item from an RFC822 (eml) message file. We want to display the mail item in an inspector but then have it be deleted and not leave any saved mail in the Drafts folder (where we temporarily have to save it).

However, we find that mail items created in this way don't fire ADX events so important events like ADXOutlookAppEvents.InspectorActivate are not being handled. I don't know enough the internals of MAPI/Redemption/ADX to know whether we can even expect this to work, but wondered if you had any input. Included a sample of our RDOMail code below.


RDOSession rdoSess = null;
RDOMail rdoMail = null;
Outlook.NameSpace ns = null;
try
{
	AddinModule addin = AddinModule.CurrentInstance as AddinModule;

	rdoSess = new RDOSession();
	ns = addin.OutlookApp.Session;
	rdoSess.MAPIOBJECT = Utils.OLLateBoundPropertyGetHelper(ns, "MAPIOBJECT");

	rdoMail = rdoSess.GetDefaultFolder(rdoDefaultFolders.olFolderDrafts).Items.Add(Missing.Value);
	rdoMail.Import("TempMessageFile.eml", 1024); // 1024 Magic number for RFC822 type
	rdoMail.Sent = true;

	rdoMail.Save();
}
finally
{
   ...
}


We then call Display on this RDOMail item to open up the inspector and display the mail. However, ADX events don't fire.

To fix the events I tried returning the OOM item from the RDOMail and calling Display on that instead.

e.g.


string entryId = rdoMail.EntryID;
object item = ns.GetItemFromID(entryId, Type.Missing);


This re-instated the missing ADX events but leaves us with a problem. We want to delete this mail programatically as it's only temporary. With the pure RDOMail solution, we could just delete the RDOMail after calling Display and the Inspector stayed open, but the mail in the drafts folder was removed.

However, if we instead call display on the OOM item returned from ns.GetItemFromID, calling Delete immediately closes the Inspector.

To work around this I tried delaying calling delete on the draft OOM mail item until the user closes the Inspector by handling either the ADXOutlookAppEvents.InspectorClose or the ADXOutlookItemEvents.ItemClose events and calling Delete on the current inspector item. However, this failed too with a COM exception:


AddinExpress.MSO.ADXExternalException: An error has occured in the code of the add-in. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040108): The item?Â?Ð?és properties and methods cannot be used inside this event procedure.


So not really sure which way to go now?

Thanks for any insights or suggestions you can give.

Martin
Posted 01 Apr, 2008 01:56:41 Top
Martin Bayly




Posts: 41
Joined: 2007-10-05
I was able to get this to "work" finally, by going back to RDOMail in my ADXOutlookItemEvents.ItemClose handler, and reloading the event handler's ItemObj as an RDOMail and deleting the item using RDOMail.Delete. However, this all seems a bit messy and convoluted so if you have any better suggestions or know if there is a way to get ADX events to fire with RDOMail items, I'd be very grateful.


string entryId = (string)Utils.OLLateBoundPropertyGetHelper(this.ItemObj, "EntryID");
AddinModule addin = AddinModule.CurrentInstance as AddinModule;
RDOSession rdoSess = null;
RDOMail rdoMail = null;
NameSpace ns = null;
try
{
	rdoSess = new RDOSession();
	ns = addin.OutlookApp.Session;
	rdoSess.MAPIOBJECT = Utils.OLLateBoundPropertyGetHelper(ns, "MAPIOBJECT");
	rdoMail = rdoSess.GetMessageFromID(entryId, null, null);
	if (rdoMail != null)
	{
		rdoMail.Delete(redDeleteFlags.dfSoftDelete);
	}
}
finally
{
	Utils.ReleaseCOMIfNotNull(rdoMail);
	Utils.ReleaseCOMIfNotNull(rdoSess);
	Utils.ReleaseCOMIfNotNull(ns);
}


Thanks
Martin


Posted 01 Apr, 2008 02:15:21 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Martin.

The fact is that Add-in Express processes all Outlook events. If some events don't fire, that means Outlook doesn't generate them at all.
Now I don't have any solution for this issue. Please use the workaround mentioned above.


Posted 01 Apr, 2008 08:15:15 Top