I am trying to "replytoall" with a given format in the Body.
I use the following code to search for and display the mails.
Sub Test()
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1
For Each olMail In Fldr.Items
If InStr(olMail.Subject, "Application for Privilege Leave - Leave ID - Dev-PL-45252-4") <> 0 Then
olMail.Display
i = i + 1
End If
Next olMail
End Sub
I need to Replyall with the same subject and a prescribed body and signature.
It is similar to when we open up a mail in Outlook and click on the Reply to All button.
I want it triggered from Excel.
Since you are using Early Binding, Change
Dim olMail As Variant
to
Dim olMail As Outlook.MailItem
And then you will be able to access all the properties of the olMail
item. One of which is .ReplyAll
ScreenShot
If InStr(olMail.Subject, "Blah Blah") <> 0 Then
olMail.Display
olMail.ReplyAll
DoEvents
'
'~~> Rest of the code
'
i = i + 1
End If