<tab id="MyTab" label="AmdocsTool" getVisible="MyTab_GetVisible"> <group id="ContentGroup" label="Content"> <button id="textButton" label="Apply for leave" screentip="Text" onAction="OnTextButton" supertip="Inserts text at the cursor location."/> <button id="tableButton" label="Cancel Leave" screentip="Table" onAction="OnTableButton" supertip="Inserts a table at the cursor location."/> </group> </tab> <tab idMso="TabMail"> <group id="ContentGroup1" label="Content"> <button id="textButton1" label="Apply for leave" screentip="Text" onAction="OnTextButton1" supertip="Inserts text at the cursor location."/> <button id="tableButton1" label="Cancel Leave" screentip="Table" onAction="OnTableButton1" supertip="Inserts a table at the cursor location."/> </group> </tab> public bool MyTab_GetVisible(Office.IRibbonControl control) { if (control.Context is Outlook.Explorer) { Outlook.Explorer explorer = control.Context as Outlook.Explorer; Outlook.Selection selection = explorer.Selection; if (selection.Count == 1) { if (selection[1] is Outlook.MailItem) { Outlook.MailItem oMail = selection[1] as Outlook.MailItem; if (oMail.Sent == true) { return true; } else { return false; } } else { return false; } } else { return false; } } else if (control.Context is Outlook.Inspector) { Outlook.Inspector oInsp = control.Context as Outlook.Inspector; if (oInsp.CurrentItem is Outlook.MailItem) { Outlook.MailItem oMail = oInsp.CurrentItem as Outlook.MailItem; if (oMail.Sent == true) { return true; } else { return false; } } else { return false; } } else { return true; } }