Problem with ItemEvents.ProcessReply, changing body of response

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

Problem with ItemEvents.ProcessReply, changing body of response
 
Michael Hoess




Posts: 5
Joined: 2007-07-02
Hello,

Using Addinexpress2007, Outlook 2003 on Win2003 with VS2005:

I have a ItemsEvents.ProcessReply like that:


public override void ProcessReply(object response, AddinExpress.MSO.ADXCancelEventArgs e)
        {
            Outlook.MailItem rsp = response as Outlook.MailItem;

            rsp.Body = rsp.Body + " X "; // Changes orignal, too!
            rsp.Subject = rsp.Subject + "X"; // works fine
        }


When I change the the rsp.body like in the code, the body of the original message is also modified.
Using the same code works fine with the ".subject" or UserProperties.

What can I do to prevent the modification of the body of the orignal
message?

Thanks,
M. Hoess






Posted 02 Jul, 2007 09:47:47 Top
Sergey Grischenko


Add-in Express team


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

Please try the following workaround:

public override void ProcessReply(object response, AddinExpress.MSO.ADXCancelEventArgs e)
{
// TODO: Add some code
IntPtr unk = Marshal.GetIUnknownForObject(this.ItemObj);
this.RemoveConnection();
object original = Marshal.GetObjectForIUnknown(unk);
(original as Outlook._MailItem).Close(Outlook.OlInspectorClose.olDiscard);
Marshal.Release(unk);
Marshal.ReleaseComObject(original);

Outlook.MailItem rsp = response as Outlook.MailItem;

rsp.Body = rsp.Body + " X ";
rsp.Subject = rsp.Subject + "X";
}



P.S. We always do our best to answer your forum requests as soon as possible. However, we apply the rule "first in first out" with Premium Support Service subscribers taking priority. Please understand it may take us some time to do research on the issue. Please be assured we will let you know as soon as the best possible solution is found.
Posted 02 Jul, 2007 11:32:01 Top
Michael Hoess




Posts: 5
Joined: 2007-07-02
Hi Sergey,

thanx for your fast reply.

I tried your code as shown above.

Unfortunately now changing the body does have no effects anymore.
Both messages (original and reply) remain unchanged.
Setting subject still works as expected.
When I check the value of rsp.Body directly
after the line rsp.Body = rsp.Body + "X"; using
the VS2005-Debugger, the cotents also shows up unchanged.

Posted 02 Jul, 2007 12:08:27 Top
Sergey Grischenko


Add-in Express team


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

I tested the code. It should work properly.
Is your Outlook connected to Exchange Server?

P.S. I tested this code in the OutlookItemEvents example from the Add-in Express installation.
Posted 03 Jul, 2007 15:45:27 Top
Michael Hoess




Posts: 5
Joined: 2007-07-02
Hi Sergey,

sorry, obviously I was confused or something yesterday. Now I did a full rebuild of my project an retested your solution, and now it works magically. Very strange.

BTW. yes, I'm, using Exchange server.

Thanx for your help
Bye
M. Hoess
Posted 04 Jul, 2007 05:01:17 Top