SetAdviseSink not called when sending a forwarded item in Outlook

C

Chris

I've implemented a form viewer based on the Microsoft FormViewer sample:
http://support.microsoft.com/default.aspx?scid=kb;en-us;230770

What I'm seeing with both my implementation and the FormViewer sample is
that there's a difference in behaviour when forwarding an item, depending on
the Outlook setting "close on forward or reply message".

When "close on forward or reply message" is disabled:
Clicking the forward button from the open message, creates a new form on
which CMyMAPIFormViewer::SetAdviseSink is called. When this new message is
sent, CMyMAPIFormViewer::SubmitMessage is called and the object is completely
destroyed. On closing the original open message,
CMyMAPIFormViewer::SetAdviseSink is called with a null parameter.

When "close on forward or reply message" is enabled:
Clicking the forward button from the open message, creates a new form on
which CMyMAPIFormViewer::SetAdviseSink is called. When this new message is
sent, CMyMAPIFormViewer::SubmitMessage is called and the object is completely
destroyed.

However in this case, the original message is closed by Outlook but
CMyMAPIFormViewer::SetAdviseSink is not called.

Does anyone have any ideas why this is so?

Thanks in advance,
Chris
 
J

Jon Ebersole

Chris, I ran into a very similar problem earlier this week. I have created
an Outlook Add-in that creates new MailItem objects and sets some user
properties and categories. If they only have 1 open at a time, my code and
events all function as expected. If they create a new MailItem, all prior
MailItems lose my event overrides.

I figured out that this was because I had my MailItem defined as a global
var in my add-in, and whenever a new MailItem was created, it set that var to
the new item losing the prior MailItem's events. To resolve this, I created
a subroutine that handles the MailItem's events, and instead of setting the
global var equal to the new mail item, I am dynamically creating each
MailItem as a tmp var during creation and adding the handler to the
MailItem's Inspector in the 'New Inspector' event using the following line..

AddHandler Inspector.Activate, AddressOf objInspector_Activate

It sounds to me like the one version of your 'close on forward or reply
message' is overwriting or nulling the original event of
CMyMAPIFormViewer::SetAdviseSink for the original message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top