Is it possible to include an If statement in a VSTO plugin that will offer up different Context Menu items based on the Current User's attributes, e.g. Department?
I am attempting to use the documentation in here https://docs.microsoft.com/en-us/office/client-developer/outlook/pia/how-to-get-information-about-the-current-user to add to my existing code:
<contextMenu idMso="ContextMenuMailItem">
<menu id="ReplyListContext" label="Choose a Quick Reply" insertBeforeMso="Copy">
<button id="CharityContext" label="Charity Request" onAction="Charity_Click"/>
>
</menu>
</contextMenu>
public void Charity_Click(Office.IRibbonControl control)
{
Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
if (explorer != null)
{
Outlook.Selection selection = explorer.Selection;
if (selection.Count >= 1)
{
Outlook.MailItem mailItem = selection[1] as Outlook.MailItem;
if (mailItem != null) //could be something other than MailItem
{
Outlook.MailItem response = mailItem.ReplyAll();
response.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
response.HTMLBody = "<p>Thanks for your e-mail</p><p>text text text</p><p>Many thanks</p> " + response.HTMLBody;
response.Send();
}
}
}
}
I have a number of these responses and want different departments to be presented with different options when they open Outlook