Hi there,
Is there anything wrong with this code.
It seems that it only pick up the first two Orange Category and Flag For Follow up email.
3rd and 4th email didn't got picked up.
Is there anything wrong with this code.
It seems that it only pick up the first two Orange Category and Flag For Follow up email.
3rd and 4th email didn't got picked up.
Sub FollowUpEmail()
Dim objNS As Outlook.NameSpace, objFolder As Outlook.MAPIFolder, _
objResItem As Object, objMail As MailItem, objResendMail As MailItem, _
olFldrItms As Items
Set objNS = GetNamespace("MAPI")
Set objFolder = _
objNS.Folders.Item("xxxx").Folders("Inbox") ' folders of your current account
Set olFldrItms = objFolder.Items
Set objResItems = _
olFldrItms.Restrict("[Categories] = 'Orange category' and [FlagRequest] ='Follow Up'")
For Each objMail In objResItems
Set objResendMail = objMail.ReplyAll
'attachment is copied
CopyAttachments objMail, objResendMail
'immediately shift to sent item when first sent in vba
With objResendMail
.HTMLBody = _
"Follow up request" & vbCrLf _
& objResendMail.HTMLBody
'.Importance = olImportanceHigh
.Categories = "Orange category"
.FlagRequest = "Follow up"
.Display
End With
With objMail
'flag items as complete and move to the sent items
objMail.Categories = ""
objMail.FlagStatus = olFlagComplete
objMail.Save
End With
Next
End Sub