Modify body of reply message when user clicks reply -- strange behavior, original msg is temporarily

M

Mike Curry

Greetings All,

I have an interesting puzzle for you Outlook Automation geniuses out there.

I have noticed an odd problem in Outlook 2000 when trying to
programmatically modify the body of a reply, when the user clicks the
reply button (in other words, during the handling of the Reply event.) I
want to change the body of the newly created reply message
before the user has a chance to edit the newly created reply message.

I am handling the MailItem.Reply event, and in the body of the
MailItem.Reply event in the "objMailItem_Reply()" handler below.

When the code snippet below gets OR sets the body of the newly created reply
message, it
appears that the original message is marked as modified ('dirty') , for the
duration of the Outlook session (restarting outlook clears the problem.) If
you reopen the original message in a new window, you will see that the body
of the original has been modified for the duration of the Outlook sesssion
(unless you tell Outlook to save the changes, in which case the
modifications are permanent.)

--- begin vba script excerpt ---
Private Sub objMailItem_Reply(ByVal Response As Object, Cancel As Boolean)
' assumes HTML format mail, non-word editor
Dim bdy As String
bdy = Response.HTMLBody
'
' if you comment out the next line, the problem still occurs,
' but no visible changes are made to the original message
Response.HTMLBody = "The original body was:" & bdy
End Sub
--- end vba script ---


A full version of the script, suitable for copy/paste into the VBA editor's
ThisOutlookSession module is on the web at:
http://www.exodus-dev.com/dropbox/OutlookQuirks/SimpleBogusMsgBodyModify.txt
or, if you prefer a short url:
http://tinyurl.com/2hz3x

Another version which includes proper checking of msg format, editor type,
etc. is at:
http://www.exodus-dev.com/dropbox/OutlookQuirks/BogusModifyOriginalMsg.txt
or, the short url:
http://tinyurl.com/2uabj


Am I doing something wrong here, or is this a known issue in Outlook? If
this is the wrong approach, can someone provide a URL or other pointer to an
example of the correct method? Any and all references/samples/pointers are
welcome!

If you don't get the same results as I do, I'd like to know about it
(including Outlook version, patch level, Internet Explorer versions, etc.)

By the way, I get the same results in a C++ COM Add-In that is doing
essentially the same thing as this script. (That's why I created the simple
script, in order to create a simple test case)
 

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