vendredi 22 mai 2015

Changing the category tag of an email according to data in excel

So I basically want to loop through each email until the subject line in found in column A matches the subject line of the email. When it has found a match, it will then look along the same row in column C and depending on what is found here (YES, NO or MULTIPLE) the category of the email will change.

Every mail is tageed as "ATLG" before the macro has run.

The code below is very much a work in progress, but I do not know where to go from here. Any suggestions?

Dim mail As Outlook.MailItem
Dim fld As Outlook.MAPIFolder

For Each mail In fld.Items
With mail
If mail.Subject = Sheets("Mail Report").Range("A65000").End(xlUp).Value Then
If Sheets("Mail Report").Range("C65000").End(xlUp).Value = "YES" Then
mail.Category = "ATLG"
If Sheets("Mail Report").Range("C65000").End(xlUp).Value = "NO" Then
mail.Category = "MAN"
If Sheets("Mail Report").Range("C65000").End(xlUp).Value = "MULTIPLE" Then
mail.Category = "MULT"
Next mail

Excel Info

Aucun commentaire:

Enregistrer un commentaire