Log in

View Full Version : runtime error 438 on accepting meeting



pyro2509
08-30-2016, 11:37 PM
I have a script that places a banner at the top of an email when it's sent. However when I want to accept a meeting request, it gives me the runtime error. It seems to put the meeting in my calendar, but the error is irritating.

If TypeOf objItem Is Outlook.MailItem And objItem.BodyFormat = olFormatHTML Then is the line with the error. It was suggested that I split the line, but I have no knowledge of VBA. This is a template I'm utilizing.
My code is as follow:


' version: 1.0'=================================================================
Dim BannerURL As String
Dim BannerTargetURL As String
Dim BannerWidth As Integer
Dim BannerHeight As Integer
Dim PromptSend As Boolean

'==================BEGIN MODIFY ================================================
BannerURL = "Link to Image"
BannerTargetURL = ""
BannerWidth = 361
BannerHeight = 61
PromptSend = False
'==================END MODIFY ==================================================

If TypeOf objItem Is Outlook.MailItem And objItem.BodyFormat = olFormatHTML Then
If PromptSend = True Then
Dim Result As VbMsgBoxResult
Result = MsgBox("Do you want to include your banner to this message?", _
vbQuestion + vbYesNo, "Add Banner")
If Result = vbNo Then
Exit Sub
End If
End If

Dim strTopHTML As String
strTopHTML = "<p><a href=""" & BannerTargetURL & """><img width=""" _
& BannerWidth & """ height=""" & BannerHeight & _
""" src=""" & BannerURL & """ /></a></p>"
strHTMLBody = objItem.HTMLBody
intTagStart = InStr(1, strHTMLBody, "<body", vbTextCompare)
intTagEnd = InStr(intTagStart + 5, strHTMLBody, ">")
strBodyTag = Mid(strHTMLBody, intTagStart, intTagEnd - intTagStart + 1)
objItem.HTMLBody = Replace(strHTMLBody, strBodyTag, strBodyTag & strTopHTML)

End IfEnd SubSub AddBanner()
End Sub