I have created an add-in that allows a user to add information concerning an email into a SQL Table.
I am currently trying to implement a quality-of-life feature that will read the subject line of an opened email from the inbox into the relevant field of the user form. I have tried several methods and have had no success.
This is what I have currently:
Dim newMail As Outlook.MailItem
Dim oInspector As Outlook.Inspector
oInspector = Microsoft.Office.Interop.Outlook.Application.ActiveInspector()
newMail = oInspector.CurrentItem
[Initializing other parts of form]
If oInspector Is Nothing Then
MsgBox("No Active Inspector")
Else
newMail = oInspector.CurrentItem
With AddEmailSubjectTextBox
.Text = newMail.Subject
End With
End If
Besides the "reference to a non-shared member requires an object reference" error that is thrown, I believe part of my issue is that the ActiveInspector method and CurrentItem are supposed to represent an email that is being written in a pop-up window and has yet to be sent.