none
capture reply/reply all for specific mail items created with outlook Redemption

    Question

  • Hi All,

    I am currently creating an outlook add-in that will download a list of mails in a DataTable and create mailItems in a specifically created folder in outlook using Redemption (using c#).

    I need to stop the user from being able to reply to those created mail items through any other Outlook account that they may have setup by either through the menu or mail context menu or any other method. Instead, I need to open a pre-defined web page URL. Can anyone please advise me how to do this?

    Also, in order to specify to my web page/web service which email the user is replying to, I need to pass a key unique to each mail item. This key is defined in the DataTable that I receive when creating the mail items. Currently I am storing this as a comment in the mailItem HTML body. I want to know if there is a (non-used) mailItem parameter in which I can store this key.

    Thanks!

    -Thimila

    Thursday, December 20, 2012 7:03 AM

Answers

  • you have to track selectionchange event on explorer object and attach to reply/replyall events on selected items. Additionally you will have to repurpose the same commands on item context menu display (and again the same commands in inspector window). This way you will be able to cancel out normal reply message processing and display your own web page. As for user properties - since you do not want to use outlook at all in this, userproperties will not help you, you will have to come up with some other way to store additional data.
    Wednesday, January 02, 2013 7:17 AM

All replies

  • Application.ItemSend event seems to be ok for your requirements. As for storing additional payload - as long as mail is sent inside organization or between exchange servers, you can use UserProperties for this. Is that the case?
    Thursday, December 20, 2012 7:34 AM
  • Hi Damian,

    Sorry for the late reply, I was away for the xmas holidays.

    The issue with the Application.ItemSend is that it fires when the mail is being sent, right? My requirement is to open a web page when the user attempts to Reply to the mail items I have created. Then the web app will take care of the process of replying. So the user must not be able to draft a reply through Outlook at all (the reply screen from outlook should not be opened). What I require is to be able to call a method of my own when the user clicks reply (or reply all) to a mail item that I created, and stop the default Outlook process.

    As I am hoping to allow the new/reply process to be through a web app, the created Outlook mail item will not be sent out of the user's Outlook application. So, accordingly you suggestion to use UserProperties to store additional payload should help me, although I am unsure on how to use it. I will attempt on it and get back to you should I come across any problems.

    Can you please let me know what is the best way for me to handle the mail reply process?

    Thanks!

    Tuesday, January 01, 2013 12:34 PM
  • you have to track selectionchange event on explorer object and attach to reply/replyall events on selected items. Additionally you will have to repurpose the same commands on item context menu display (and again the same commands in inspector window). This way you will be able to cancel out normal reply message processing and display your own web page. As for user properties - since you do not want to use outlook at all in this, userproperties will not help you, you will have to come up with some other way to store additional data.
    Wednesday, January 02, 2013 7:17 AM
  • Thanks for the reply Damian.

    What I need is to store a key value that will define the mail item for my web app. So the data needs to be on the mail item itself. Do you know if there any property exposed through the redemption RDOMail object that can be used to store this?

    Thursday, January 03, 2013 7:07 AM
  • i have to admit i do not get it - you want to hijack reply process so no new mailitem is created or displayed in outlook. So where in outlook do you want to store information? on original mail on which user clicked Reply command?
    Thursday, January 03, 2013 8:38 AM
  • Yes.

    Well, I want to store the information when creating the mail items, not after the user clicks reply. When the user clicks reply, I want to be able to read that information off the selected mail item and then pass it (the info) to my web page.

    Thursday, January 03, 2013 9:51 PM
  • ok, in such case you can use UserProperties on that mailitem, available both from OOM and Redemption API
    Friday, January 04, 2013 5:14 AM
  • Thanks Damian, that solved my issue with storing additional data on the mail item. I had to use the RDOMail.set_Fields() and RDOMail.get_Fields() encapsulation methods as Redemption does not expose UserProperties on C#.

    However, I am lost at capturing the reply/replyAll events. The thing is, I can't seem to find a reply or replyAll EVENT (or anything corresponding) on the RDOMail item in C#. There is a METHOD, but it is a method group and cannot be added/manipulated. But given my requiremnts, I guess it is an EVENT that I need.

    As I said before, I am creating these mail items myself in my add-in, and I need to hijack the reply/replyAll process for those items ONLY. So if there is a way to attach an event handler to a reply/replyAll event (or any other way to handle the process according to what I require) during item creation, it would actually be better.

    Sunday, January 06, 2013 10:25 PM
  • redemtption _does_ expose userproperties, look at http://www.dimastr.com/redemption/rdouserproperties.htm (on rdomail). As for events - RDO* objects encapsulate MAPI level data, those events are stricctly UI related and therefore not available on MAPI level. Use standard OOM MailItem for this.
    Monday, January 07, 2013 8:56 AM
  • Hi Damian, Thanks for your help.

    Yet I am unable to see (in intellisense or runtime - attempting to gives build errors) the Reply/ReplyAll events in OOM even? I have included below the relevant code snippets from my application. In the OnSelectChange method, the OOM mailItem object does not expose a reply or replyAll event that can be attached to (like given here). Were these events not exposed in Outlook2003 by any chance? (as I am using 2003 currently)

    public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
    {
       _ApplicationObject = (Microsoft.Office.Interop.Outlook.Application)application;
       currentExplorer = _ApplicationObject.ActiveExplorer();
       currentExplorer.SelectionChange += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(this.OnSelectChange);
                
       _addInInstance = addInInst;
    
       if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
       {
          OnStartupComplete(ref custom);
       }
    }
    
    public void OnSelectChange()
    {
       foreach (object obj in currentExplorer.Selection)
       {
          Microsoft.Office.Interop.Outlook.MailItem mailItem = obj as Microsoft.Office.Interop.Outlook.MailItem;
          if (mailItem != null)
          {
             try
             {
                Redemption.RDOSession rdoSession = new Redemption.RDOSession();
                rdoSession.MAPIOBJECT = _ApplicationObject.Session.MAPIOBJECT;
                Redemption.RDOMail rdoMail = rdoSession.GetMessageFromID(mailItem.EntryID);
                string key = (string)rdoMail.get_Fields("my_Key");
                if (string.IsNullOrEmpty(key) == false)
                {
                   <I need to set the reply/replyAll events here>
                }
             }
             catch { }
          }
       }
    }

    Tuesday, January 08, 2013 3:39 AM
  • Hi, I just figured out the problem...although I am still far from a solution!! Please help?

    The Reply/ReplyAll events are "hidden" by the respective method groups. I am getting the following warning/message when trying to bind to the reply event:

    Ambiguity between method 'Microsoft.Office.Interop.Outlook._MailItem.Reply()' and non-method 'Microsoft.Office.Interop.Outlook.ItemEvents_10_Event.Reply'. Using method group.

    The related code:

    mailItem.Reply += new Microsoft.Office.Interop.Outlook.ItemEvents_10_ReplyEventHandler(this.myReply);
    
    
    
    public void myReply(object x, ref bool y)
    {
    }


    ---- EDIT ------



    Resolved!!

    The code to hook the event is:

    ((Microsoft.Office.Interop.Outlook.ItemEvents_10_Event)mailItem).Reply += new Microsoft.Office.Interop.Outlook.ItemEvents_10_ReplyEventHandler(myReply);

    Thanks Damian for all your help!!

    Tuesday, January 08, 2013 5:52 AM
  • You need to explicitly cast to ItemEvents_10 to avoid ambiguity.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!


    Tuesday, January 08, 2013 6:14 AM
  • Thanks Dmitri!!
    Tuesday, January 08, 2013 10:01 PM