I am trying to get the email item currently being edited when I reply to an email in the current window of a VSTO Outlook add-in. I am using the following code to get the item and add an attachment, but when I reply in the current window, the
Globals.ThisAddIn.Application.ActiveInspector() returns null:
private void AddAttachment(IEnumerable<string> filePathList)
var inspector = Globals.ThisAddIn.Application.ActiveInspector();
if (inspector != null && inspector.CurrentItem is Outlook.MailItem mailItem)
foreach (var filePath in filePathList)
//add attachment to current mail
How can I modify the code to successfully get the email item I am editing when replying to an email in the current window?