How to use Redemption to set ReplyRecipients and still be able to see them in Message Options?

O

Oliver Giesen

Hi all!

I'm trying to write a addin that automatically sets the ReplyTo
header on unsent outgoing mails depending on context either from within
an appropriate event handler (e.g. NewInspector or another Item's Reply
event). This would actually already work fine by simply adding names to
the mail item's ReplyRecipients collection but that way I get the OL
security warnings...

Now, the obvious solution seems to be to use Redemption and indeed when
doing the same using the corresponding Redemption Objects all appears
to work fine - at first that is. Messages do get sent out with the
correct ReplyTo address set but when I open the Message Options dialog
before sending the message, the "Have replies sent to" option is
unchecked and when I close the dialog again, no ReplyTo will be set.
Likewise, peeking at the message object with OutlookSpy reveals an
empty ReplyRecipients collection.

I guess this is because the mail item that the inspector edits is more
or less detached from the one that is accessed via the Redemption
wrappers... but how to overcome this?
I know of several addins that do manage to set the ReplyTo without
these problems so I know it must be possible but currently I don't know
what else to try... I'd rather like to avoid messing around with
sending window messages to the Message Options dialog...
Any ideas?

Cheers,
 
K

Ken Slovak - [MVP - Outlook]

Do you call .Save on the item? Try that before looking at things with
OutlookSpy or the Outlook user interface.
 
D

Dmitry Streblechenko

Outlook cannot see changes made with Extended MAP until you completely
dereference the message and reopen it. Since you are using NewInspector
event, there is no way to reopen the message.
I don't know if it'll work with the ReplyRecipients, but to make change to
the Recipients collection visible, you can try to add a property using
MailItem.UserProperties.Add (doesn't matter what property), set the property
value, then immediately delete it - this seems to force Outlook to refresh
the recipients collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
O

Oliver Giesen

Dmitry said:
Outlook cannot see changes made with Extended MAP until you
completely dereference the message and reopen it. Since you are using
NewInspector event, there is no way to reopen the message.

Hmm OK, are there maybe any other alternatives for setting the Reply-To
header besides ReplyRecipients that would potentially be noticed by the
Outlook UI?
For instance Victor's SetFrom addin (http://ivasoft.biz/setfrom.shtml)
manages to do this apparently without even resolving the reply
recipient first AFAICT...

I don't know if it'll work with the ReplyRecipients, but to make
change to the Recipients collection visible, you can try to add a
property using MailItem.UserProperties.Add (doesn't matter what
property), set the property value, then immediately delete it - this
seems to force Outlook to refresh the recipients collection.

Nope, didn't seem to work...
At what point would you have called that? Before or after saving the
item (as Ken suggested)? Or does saving having no impact here?

BTW: It seems I couldn't call Item.Save from within the Reply event
handler? I always get an exception saying "An invalid argument was
supplied as a parameter" which seems a bit odd seeing that Item.Save is
a parameter-less function... an unhandled error in Outlook itself?

Cheers,
 
O

Oliver Giesen

Dmitry said:

Hmm, have I maybe missed anything? I don't see how that would solve my
problem at all. The question was how to set the Reply-To header so that
the Outlook UI can see it. AFAICT the solution described in that FAQ
would be even worse than my original one in that respect as the change
would not even be visible in the sent item... or did I just get that
hint wrong completely?

2. Try to use Inspectors.NewInspector event rather than Item.Reply.

Yep, figured that out by now. The problem is that I need information
about the item that is being replied to which is not available from the
NewInspector event (or is it?). However I now did some tests with
passing the information gathered in the Item.Reply event on to the
Inspector.Activate event handler via Item.UserProperties which seemed
to work ok.


Anyway, as for my original problem I have now settled to do the dirty
thing and manipulate the Message Options dialog from a watcher thread
using Window Messages (in addition to setting
ISafeMailItem.ReplyRecipients). It actually works rather nicely but
it's certainly not ideal. If anyone has a better idea feel free to drop
me a note.

Cheers,
 
D

Dmitry Streblechenko

1. That method would allow you to set the Reply-To headers directly, but it
won't be visible in the Outlook UI of course.
Victor's SetFrom addin also uses Redemption to set the Reply recipients to
the best of my knowledge... You migth want to get in touch with him to see
how he did it.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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