none
How to add flag for a composing message in Outlook 2010 RRS feed

  • Question

  • I want to set a flag for a composing message for me only (not for recipients) in outlook by vsto code, or just set a flag for the corresponding mail in sent items.  Is possible? Please help me…

    Jenus M
    Monday, December 10, 2012 6:58 AM

Answers

  • Hi Jenus,

    Thanks for posting in the MSDN Forum.

    I think we must confirm your goal first. It will work if you only want to set a category for the mail which you want to send on your client. Following code show your how to do it:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Office.Tools.Ribbon;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using System.Windows.Forms;
    namespace OutlookAddIn5
    {
        public partial class Ribbon1
        {
            private Outlook.Application olApp = null;
            private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
            {
                olApp = Globals.ThisAddIn.Application;
                gallery1.Items.Clear();
                foreach (Outlook.Category olCategory in olApp.Session.Categories)
                {
                    RibbonDropDownItem rddi = new RibbonDropDownItem();
                    rddi.Label = olCategory.Name;
                    gallery1.Items.Add(rddi);
                }
            }
            private void gallery1_Click(object sender, RibbonControlEventArgs e)
            {
                if (sender is RibbonGallery)
                {
                    RibbonGallery RG = (RibbonGallery)sender;
                    Outlook.MailItem olMailItem = olApp.ActiveInspector().CurrentItem as Outlook.MailItem;
                    if (olMailItem != null)
                    {
                        // Set Flag text here such as "Today","Tomorrow" etc.
                        olMailItem.FlagRequest = "Next Week";
                    }
                    else
                    {
                        MessageBox.Show("Failure");
                    }
                }
                else
                {
                    MessageBox.Show("NULL");
                }
            }
        }
    }

     

    It will not work if you want to add category on the receivers' client. The work round for this statement is create a add-in and let customer load the add-in and sent your category as some kind of customized property.

    I hope what I said can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, December 11, 2012 5:17 AM
    Moderator

All replies

  • yes, what exactly gives you problems?
    Monday, December 10, 2012 7:34 AM
  • Hi Jenus,

    Thanks for posting in the MSDN Forum.

    I think we must confirm your goal first. It will work if you only want to set a category for the mail which you want to send on your client. Following code show your how to do it:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Office.Tools.Ribbon;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using System.Windows.Forms;
    namespace OutlookAddIn5
    {
        public partial class Ribbon1
        {
            private Outlook.Application olApp = null;
            private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
            {
                olApp = Globals.ThisAddIn.Application;
                gallery1.Items.Clear();
                foreach (Outlook.Category olCategory in olApp.Session.Categories)
                {
                    RibbonDropDownItem rddi = new RibbonDropDownItem();
                    rddi.Label = olCategory.Name;
                    gallery1.Items.Add(rddi);
                }
            }
            private void gallery1_Click(object sender, RibbonControlEventArgs e)
            {
                if (sender is RibbonGallery)
                {
                    RibbonGallery RG = (RibbonGallery)sender;
                    Outlook.MailItem olMailItem = olApp.ActiveInspector().CurrentItem as Outlook.MailItem;
                    if (olMailItem != null)
                    {
                        // Set Flag text here such as "Today","Tomorrow" etc.
                        olMailItem.FlagRequest = "Next Week";
                    }
                    else
                    {
                        MessageBox.Show("Failure");
                    }
                }
                else
                {
                    MessageBox.Show("NULL");
                }
            }
        }
    }

     

    It will not work if you want to add category on the receivers' client. The work round for this statement is create a add-in and let customer load the add-in and sent your category as some kind of customized property.

    I hope what I said can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, December 11, 2012 5:17 AM
    Moderator