none
How can I create a new mail custom form shortcut ? RRS feed

  • Question

  • Hello everyone !

    It's been three hard day of searching for such a simple question:

    How can I add a button to Outlook's ribbon that select a new pre-define form to send ?

    I already have the button but I miss an instruction like that:

    Create new mail with the form located here

    Thank you in advance for helping :D

    (And sorry if there is a mistake, English is not my native language)

    Wednesday, April 29, 2015 1:40 PM

Answers

All replies

  • Hello Dark,

    private void CreateMailItem()
    {
        Outlook.MailItem mailItem = (Outlook.MailItem)
            this.Application.CreateItem(Outlook.OlItemType.olMailItem);
        mailItem.Subject = "This is the subject";
        mailItem.To = "someone@example.com";
        mailItem.Body = "This is the message.";
        mailItem.Importance = Outlook.OlImportance.olImportanceLow;
        mailItem.Display(false);
    }

    Outlook forms are associated with items based on the message class values. To get a specific inspector window displayed you need to create an Outlook with the associated message class.

    VSTO provides two different ways for customizing the Fluent UI:

    1. Using the ribbon designer: Walkthrough: Creating a Custom Tab by Using the Ribbon Designer .

    2. A raw XML markup: Walkthrough: Creating a Custom Tab by Using Ribbon XML


    Wednesday, April 29, 2015 1:58 PM
  • Application.CreateItem(olMailItem) will create a regular IPM.Note item. To create an item specifying the explicit class, use MAPIFolder.Items.Add. E.g.

    Outlook.MAPIFolder drafts = Application.Session.GetDefautlFolder(OlDefaultFolders.olFolderDrafts);
    mailitem = drafts.Items.Add("IPM.Note.MyCustomClass");

     

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

    Wednesday, April 29, 2015 5:06 PM
  • Thanks for your reply!

    How do I use "Application.Session..." or this.Application ?

    It does not exist in my context :$

    What am I supposed to put in this:

                

    private void button1_Click(object sender, RibbonControlEventArgs e)
    {

    }

    Thank you for reading my (stupid) questions :)


    Thursday, April 30, 2015 8:15 AM
  • Hello Dark,

    If you develop an add-in you can use the Application property provided by the VSTO runtime. You can access it anywhere using the Global.ThisAddin.Application property.

    Thursday, April 30, 2015 11:58 AM