i want to Copy selected Text from WordEditor(Body of Outlook Email) to another Form when i searched i found that part of code to Copy to new Word Document by using Microsoft.Office.Interop.Word.Document
Outlook.MailItem mailItem;
Outlook.Inspector inspector = mailItem.GetInspector;
// Obtain the Word.Document object from the Inspector object
Word.Document document = (Word.Document)inspector.WordEditor;
// Copy the selected objects
document.Application.Selection.Copy();
i always get Error with mailItem.GetInspector part ( Object refrence is not set to instance of object )
for starters you are not using the OutLook.MailItem properly.. use something like this as a test and utilize it and make changes as you see fit to fit your UseCase
OutLookMailItem how to use Outlook
Set the MailItem object to "objExplorer.Selection[1] as Microsoft.Office.Interop.Outlook.MailItem;" where objExplorer = AddIn name.Globals.ThisAddIn.Application.ActiveExplorer();
You need to request the active inspector from the
Application
object.Globals.ThisAddIn.Application.ActiveInspector()
will provide you with the currently active inspector reference which you can then request theCurrentItem
and convert to aMailItem
reference if the item is aMailItem
type (could also be a CalendarItem, TaskItem, NoteItem, etc.).