vbaoutlookmailitem

Writeable active inline response in outlook


I have the following code from some blog that inserts HTML from the clipboard into an outlook email.

Sub PrependClipboardHTML()
Dim email As Outlook.MailItem
Dim cBoard As DataObject

Set email = Application.ActiveInspector.CurrentItem
Set cBoard = New DataObject


cBoard.GetFromClipboard
email.HTMLBody = cBoard.GetText + email.HTMLBody

Set cBoard = Nothing
Set email = Nothing

End Sub

It works great except that the email has be in its own window (i.e. popped-out) otherwise it will fail.

I was looking around on the documentation and found Application.ActiveExplorer.ActiveInlineResponse here.

However the documentations says that it is read-only, and indeed it does not work. Is there way to get a writable version of the inline response?


Solution

  • It works great except that the email has be in its own window (i.e. popped-out) otherwise it will fail.

    That is because you have the following statement in the code:

    Set email = Application.ActiveInspector.CurrentItem
    

    However the documentations says that it is read-only, and indeed it does not work.

    Try to use the following code instead:

    Set email = Application.ActiveExplorer.ActiveInlineResponse
    

    The ActiveInlineResponse property is read-only, but not the object's properties you are going to use. That means you can't set another mail item to the inline response, but will be able to set up properties of the retrieved item.