Determine the "To" field in a replied-to message?

  • Thread starter Thread starter joebob
  • Start date Start date
J

joebob

I'm using a custom form for replies. In the code for the custom form, is there a way to programmatically determine the e-mail address in the "To" field of the message being replied to?
 
Iterate its Recipients collection, checking the Type property of each
Recipient. Remember there may be more than one To address.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



I'm using a custom form for replies. In the code for the custom form, is
there a way to programmatically determine the e-mail address in the "To"
field of the message being replied to?
 
I thought of that, but how would I do that from the reply form? In other words, I receive a message and hit the Reply button. In the custom Reply form that opens up, how do I refer back to the Recipients collection of the original message that I'm replying to? Thanks
 
How are you invoking the custom reply form? That's where you'll need to
interate the original item's Recipients collection. You haven't said what
you want to do with it yet.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



I thought of that, but how would I do that from the reply form? In other
words, I receive a message and hit the Reply button. In the custom Reply
form that opens up, how do I refer back to the Recipients collection of the
original message that I'm replying to? Thanks
 
Hi Sue,

I'm invoking the custom reply form by simply clicking Reply, or selecting Actions -> Reply from the toolbar, or Control+r on the keyboard. In other words my custom reply form comes up no matter where I invoke reply from.

I gather from what you're saying that I will have to code a function, and call it from a toolbar button or something, that handles my reply code or passes off to the code in my custom reply form. I was hoping to have my custom reply form be self-contained and not have to rely on a toolbar button or other external functionality. There are other things my reply form does besides just this function so is why I am keen on having it be self-contained.

What I'm doing with the information (the Recipients collection of the original message) is shelling out to an external app with it. Thanks
 
The problem is that the reply could be to any number of messages -- the
message selected in the Explorer or any message open in an Inspector. You
certainly could compare the subject of your reply with the subject of all of
those messages and then sender/To, if necessary, but if you have two
messages with the same sender and subject, there would be no way to know
which one you're replying to.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Hi Sue,

I'm invoking the custom reply form by simply clicking Reply, or selecting
Actions -> Reply from the toolbar, or Control+r on the keyboard. In other
words my custom reply form comes up no matter where I invoke reply from.

I gather from what you're saying that I will have to code a function, and
call it from a toolbar button or something, that handles my reply code or
passes off to the code in my custom reply form. I was hoping to have my
custom reply form be self-contained and not have to rely on a toolbar button
or other external functionality. There are other things my reply form does
besides just this function so is why I am keen on having it be
self-contained.

What I'm doing with the information (the Recipients collection of the
original message) is shelling out to an external app with it. Thanks

Sue Mosher said:
How are you invoking the custom reply form? That's where you'll need to
interate the original item's Recipients collection. You haven't said what
you want to do with it yet.
 
OK, that makes sense.

While perusing Google articles, I found this suggestion from you: http://groups.google.com/groups?hl=...e=UTF-8&selm=u5%23AKWPKCHA.2456%40tkmsftngp09. I was thinking I could utilize it as an alternative approach. I'm having trouble getting it to work though, particularly these lines:

Set objNS = Application.GetNamespace("MAPI")
Set objParent = objNS.GetItemFromID(Item.BillingInformation, Item.Mileage)

What event handler in the reply form would get those lines? I just need a basic example to get me going. Thanks
 
If you want to get that information when the item opens, you'd use the
Item_Open event handler.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



OK, that makes sense.

While perusing Google articles, I found this suggestion from you:
http://groups.google.com/groups?hl=...e=UTF-8&selm=u5%23AKWPKCHA.2456%40tkmsftngp09.
I was thinking I could utilize it as an alternative approach. I'm having
trouble getting it to work though, particularly these lines:

Set objNS = Application.GetNamespace("MAPI")
Set objParent = objNS.GetItemFromID(Item.BillingInformation, Item.Mileage)

What event handler in the reply form would get those lines? I just need a
basic example to get me going. Thanks
 
I used the Item_Reply event since that is the one I'm responding to. Here is the problem I'm having now:

The following code works great if I use one form with separate compose and read layouts. Is there a way to do this using a custom form just for composing, and the default Outlook form for reading? I tested this using FormSwap.exe to make the change in the registry, but when I hit Send I get this error: "Could not open the item. Try again. Line No:8".

Function Item_Reply(ByVal Response)
Response.BillingInformation = Item.EntryID
Response.Mileage = Item.Parent.StoreID
End Function

Function Item_Send()
Set objNS = Application.GetNamespace("MAPI")
Set objParent = objNS.GetItemFromID(Item.BillingInformation, Item.Mileage)
for each r in objParent.Recipients
msgbox r.Address
next
End Function
 
When you create an item using a custom for substituted for the default, that
item has the MessageClass of your custom form, unless you set it to a
different message class in the ITem_Write event handler.

If the item is no longer available, you'd certainly get an error. If you
include an On Error Resume Next statement in your procedure declarations,
Outlook will just ignore the error.


--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



I used the Item_Reply event since that is the one I'm responding to. Here
is the problem I'm having now:

The following code works great if I use one form with separate compose and
read layouts. Is there a way to do this using a custom form just for
composing, and the default Outlook form for reading? I tested this using
FormSwap.exe to make the change in the registry, but when I hit Send I get
this error: "Could not open the item. Try again. Line No:8".

Function Item_Reply(ByVal Response)
Response.BillingInformation = Item.EntryID
Response.Mileage = Item.Parent.StoreID
End Function

Function Item_Send()
Set objNS = Application.GetNamespace("MAPI")
Set objParent = objNS.GetItemFromID(Item.BillingInformation,
Item.Mileage)
for each r in objParent.Recipients
msgbox r.Address
next
End Function
 
Back
Top