agent_maxine
New Member
- Joined
- Aug 23, 2017
- Messages
- 38
I found a code somewhere that enables users to ReplyAll to a selected email in MS Outlook. I would also like to add a pre-defined set of texts while keeping the history of email trail. I've seen this type of code quite often:
However I keep getting "Run-time error 287: Application-defined or object-defined error." on the ".HTMLBody = EmailBody & .HTMLBody" line.
What am I missing?
Thank you in advance for any help!
.HTMLBody = EmailBody & .HTMLBody
However I keep getting "Run-time error 287: Application-defined or object-defined error." on the ".HTMLBody = EmailBody & .HTMLBody" line.
What am I missing?
Code:
Sub ReplyAll_Attachments
'Create Email as ReplyAll
'Reference Required: VBE > Tools > References > Microsoft Outlook 15.0 Object Library
Dim outlookApp As Outlook.Application, outlookMail As Outlook.MailItem, outlookReply As Outlook.MailItem
Dim outlookItem As Object, EmailBody As String
Set outlookApp = New Outlook.Application
Set outlookMail = outlookApp.CreateItem(0)
Set outlookItem = GetCurrentItem()
EmailBody = "Hello there"
If Not outlookItem Is Nothing Then
Set outlookReply = outlookItem.ReplyAll
With outlookReply
.HTMLBody = EmailBody & .HTMLBody
.Display
outlookItem.UnRead = False
End With
End If
Set outlookReply = Nothing: Set outlookItem = Nothing: Set outlookMail = Nothing: Set outlookApp = Nothing
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Outlook.Application
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
Thank you in advance for any help!
Last edited: