Hello, Wondering if someone can help me. I have created this Macro to reply to emails with a template. It works great until I try and reply to a meeting invite. I get a type mismatch error and I am thinking that it may be that these are .ics items and that's causing the issue. Any help would be much appreciated. VBA code found below.
Sub ReplyAll()
Dim origEmail As Object
Dim replyEmail As Object
Set origEmail = GetCurrentItem()
Set replyEmail = Application.CreateItemFromTemplate("C:\Users\Meeting Minutes.oft")
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Subject = origEmail.Subject + " - Meeting Minutes"
replyEmail.To = origEmail.To
replyEmail.CC = origEmail.CC
replyEmail.Display
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
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
Sub ReplyAll()
Dim origEmail As Object
Dim replyEmail As Object
Set origEmail = GetCurrentItem()
Set replyEmail = Application.CreateItemFromTemplate("C:\Users\Meeting Minutes.oft")
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Subject = origEmail.Subject + " - Meeting Minutes"
replyEmail.To = origEmail.To
replyEmail.CC = origEmail.CC
replyEmail.Display
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
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