As referenced from this post, Excel VBA for searching in mails of Outlook, I changed the code slightly to resend all emails to the same recipient in the "sent items" folder.
Function ReplyEmail()
Dim olMail
Dim olMails
Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set olFldr = olNs.GetDefaultFolder(olFolderSentMail)
Set olMails = olFldr.Items
For Each olMail In olMails
olMail.ReplyAll
olMail.Importance = 2
olMail.Subject = "RE: 2ND " & olMail.Subject
olMail.Send
Next olMail
End Function
However, for some strange reason, this function sends only half of all emails in designated folder. If there are 9 emails, the function sends out 5 (4 left), then if I run another iteration, the function sends out 2, and so on...
If I change olMail.Send
to olMail.Display
, then the function displays all emails in pop-up frames.
Has any one encountered this issue or know what's the reason behind it?
Thanks.