none
Change Mail Body from Meeting window - Contact Attendees -> Replay to All with E-mail in C# RRS feed

  • Question

  • Hey,

    I'm writing an addon with C# for Outlook 2010. When the Meeting window is open - there is an option to send email to all the attendees. How can I know when the user clicked on this command so I can change the body of the email from code?

    Thanks a lot,

    Seif.


    Seif.

    Thursday, February 27, 2014 11:45 AM

Answers

All replies

  • Hello Seif,

    The Temporarily Repurpose Commands on the Office Fluent Ribbon article in MSDN describes the required steps for intercepting Fluent UI built-in controls. The <command> element in the Ribbon XML markup can used for this. You just need to specify the IdMso value of the built-in control as the article describes. You can find the full list of Office 2013 built-in controls in the Office 2013 Help Files: Office Fluent User Interface Control Identifiers .

    Also you may be interested in the series of articles in MSDN:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)


    Finally, be aware that not all controls can be repurposed. Only button, toggleButton and checkBox can be repurposed.  
    Thursday, February 27, 2014 12:06 PM
  • Thanks a lot... I think I found the command - it is calles: ReplyToAllAttendeesWithMessage which is in the TabAppointment tab and its policy id is 1984.

    But I did not found anywhere how can I trigger this button click event.

    Any idea how can I do that?


    Seif.

    Thursday, February 27, 2014 12:35 PM
  • Seif,

    Please see the Temporarily Repurpose Commands on the Office Fluent Ribbon article in MSDN. It describes your task in the step-by-step manner. 

    Thursday, February 27, 2014 12:44 PM
  • Thanks a lot.

    I found a good solution in the following link:


    http://social.msdn.microsoft.com/Forums/vstudio/en-US/c1db32ec-f76b-4552-98da-5510362c927c/hello-ribbonxml-its-iribbonextensibility-create-method-in-thisaddincs-stops-addin-from-loading?forum=vsto


    Now everything is working - but the Click event override the original click event. So, shall I impelement the Send Mail from scratch? meaning - I need to get the current AppointmentItem from the Inspector and then create a mail and add the Attendees to the To fields and build the Body from scrach?

    The Reply to all appears as following:

    public void ThisAddIn_ReplyToAllAttendeesWithMessage(Office.IRibbonControl control, ref bool cancelDefault)
    {
                Outlook.Inspector insp = Globals.ThisAddIn.Application.ActiveInspector();
                Outlook.AppointmentItem meeting = insp.CurrentItem as Outlook.AppointmentItem;
    
                MessageBox.Show("The button has been temporarily repurposed.");
                //cancelDefault = false;
     }

    I removed the cancelDefault but it seems the new email window is not shown - so the method cancelled the regular Outlooks behavior and it expects me to write the method from scrach. Is that correct?


    Thanks,


    Seif.


    • Edited by Seif Ibrahim Thursday, February 27, 2014 2:28 PM
    Thursday, February 27, 2014 2:27 PM
  • The original Click event should go to your handler if your XML provides an onAction callback for the command. When your handler is called you can set CancelDefault == true to not go to the original button code after your code, or set it false to go to the original code after yours executes. It's your decision whether or not the original handler executes after your handler.

    Ken Slovak MVP - Outlook

    Thursday, February 27, 2014 3:28 PM
    Moderator
  • Seif,

    Nope. The default action is launched until you set the cancelDefault argument to true in the callback. Just keep it untouched in the code and the standard actions will be launched right after your code/callback.


    Thursday, February 27, 2014 3:32 PM
  • Thanks a lot... Yes, it works... But how can I now change the body of the new email? I want to add to that email a new data to its body according to the data on the meeting itself.

    Is there a way to update the body of the email window that already has been opened from my addon? or from the public void ThisAddIn_ReplyToAllAttendeesWithMessage(Office.IRibbonControl control, ref bool cancelDefault) method?

    To be more clarified - when clicking on the replay to all attendees the following message format is beening created in a new email window:

    [Signature]

    -----Original Appointment-----
    From: [From]
    Sent: Saturday, February 15, 2014 09:30
    To: [Attendees]

    Subject: [Subject]
    When: Thursday, March 06, 2014 10:45-11:00 (UTC+02:00) Jerusalem.
    Where: [Location]

    [Body of the meeting message]

    My question - is there a way to add more data to the end on this window without creating the mail message from scratch?


    Seif.


    • Edited by Seif Ibrahim Sunday, March 2, 2014 8:31 AM Adding more infor
    Sunday, March 2, 2014 8:18 AM
  • Hello Seif,

    The Outlook object model provides the NewInspector event (is fired whenever a new inspector window is opened, either as a result of user action or through program code) of the Inspectors class and the Activate event (is fired when an inspector becomes the active window, either as a result of user action or through program code) of the Inspector class.

    So, if you launch the command described above programmatically these events will be fired. In the code you can set up a flag (for example, a boolean variable) which indicates whether you need to take any actions in the upcoming Inspector's event handler or not. I'd recommend waiting for the Activate event and then modifying the body property.

    Sunday, March 2, 2014 12:25 PM
  • Thanks.. I've just created a new MailItem and created everythink from scratch.

    Thanks a lot.


    Seif.

    Monday, March 3, 2014 11:27 AM