My script automatically responds to the first email with a subject that matches after looking through a group inbox subfolder. Then it replies to everyone. I am unable to append my text to the remainder of the email after I have filled it in. only either or. I've observed numerous solutions to issues of a similar nature. HTMLBody is equal to "test". When the debug hits this line, the second option is HTMLBody. "Application-defined or object-defined error" is displayed for HTMLBody. Any suggestions as to what the issue might be or where I might find the information from the chain of emails I need to submit would be highly appreciated.
Dim olMail As Outlook.MailItem
Dim olReply As Outlook.MailItem
Dim olItems As Outlook.Items
Dim olNS As Namespace
Dim olMailbox As Folder
Dim olFolder As Folder
Dim subFolder As Folder
Dim BodyText As String
Set olNS = GetNamespace("MAPI")
Set olMailbox = olNS.Folders("Group_Inbox")
Set olFolder = olMailbox.Folders("test_Folder")
Set subFolder = olFolder.Folders("test_subFolder")
Set olItems = subFolder.Items
TheDate = Format(Date, "DD-MM-YYYY")
TheDate1 = Format(Date, "YYYY-MM")
TheDate2 = Format(Date, "YYYYMMDD")
TheDate3 = Format(Date, "YYYY")
'Find most recent email and populate
olItems.Sort "ReceivedTime", True
For i = 1 To olItems.Count
Set olMail = olItems(i)
If InStr(olMail.Subject, "Desired_Subject " & TheDate) > 0 Then
Set olReply = olMail.ReplyAll
.To = "Recipients@gmail.com"
.CC = ""
.Subject = "Test_Subject"
.BodyFormat = olFormatHTML
.HTMLBody = "This is a test email sending in Excel" & .HTMLBody ' This is the problem line.