ShekharBorker
Programmer
I am facing a prblem when trying to set up an Outlook rule that changes the subject of the mail-item and moves it to a PST folder.
The rule that I have created is as follows:
Apply this rule after the message arrives
with 'EXADXX' in the message header
and on this machine only
move it to Archive folder
and run Project1.ThisOutlookSession.RptManage
The RptManage is as follows
However, the mail-item is moved to the Archive folder without changes in the subject line. I have tried the following things:
1. I removed the Move To Folder action from the rule. In this case, the subject is changed.
2. I created two rules one for changing the subject and the other for moving it to the PST. I also ordered the rules to have the subject rule before the folder rule. The result is that the mail-item is moved to Archive folder without any changes to the subject.
3. I have tried removing the Move to Folder action from the rule and using the mail-item "Move" method within the macro as follows:
When the rule executed the subject had changed but the mail-item hadn't moved to the Archive folder.
Could you please confirm whether my requirement can be met using Rules + VBA Macros?
Also, I am not sure why I am getting the results. Any help on this is much appreciated.
Thanks
Shekhar Borker
The rule that I have created is as follows:
Apply this rule after the message arrives
with 'EXADXX' in the message header
and on this machine only
move it to Archive folder
and run Project1.ThisOutlookSession.RptManage
The RptManage is as follows
Code:
Sub RptManage(MItem As Outlook.MailItem)
ODATE = Mid("" & MItem.ReceivedTime, 7, 4) & Mid("" & MItem.ReceivedTime, 7, 4)
MItem.Subject = " ODAT: " & ODATE & " " & MItem.Subject
MItem.Save
End Sub
However, the mail-item is moved to the Archive folder without changes in the subject line. I have tried the following things:
1. I removed the Move To Folder action from the rule. In this case, the subject is changed.
2. I created two rules one for changing the subject and the other for moving it to the PST. I also ordered the rules to have the subject rule before the folder rule. The result is that the mail-item is moved to Archive folder without any changes to the subject.
3. I have tried removing the Move to Folder action from the rule and using the mail-item "Move" method within the macro as follows:
Code:
Sub RptManage(MItem As Outlook.MailItem)
Dim ns As NameSpace
Dim ArchFolder As MAPIFolder
ODATE = Mid("" & MItem.ReceivedTime, 7, 4) & Mid("" & MItem.ReceivedTime, 7, 4)
MItem.Subject = " ODAT: " & ODATE & " " & MItem.Subject
MItem.Save
Set ns = Application.GetNamespace("MAPI")
ArchFolder = ns.Folders.Item("Archive")
Mitem.Move(ArchFolder)
End Sub
When the rule executed the subject had changed but the mail-item hadn't moved to the Archive folder.
Could you please confirm whether my requirement can be met using Rules + VBA Macros?
Also, I am not sure why I am getting the results. Any help on this is much appreciated.
Thanks
Shekhar Borker