Srinevasand
Member
- Outlook version
- Outlook 2013 32 bit
- Email Account
- IMAP
Hi, I'm looking for an outlook macro that moves mails to when replied to a specific folder based on the key in the Subject Line.
Whenever I reply from the "In Progress Folder" I will add a keyword to the Subject line. if the I add Completed in the Subject line that mail has to move to "Completed Folder" and Whenever I reply from the "In Progress Folder" and if the I add a word Cancelled in the Subject line that mail has to moved to "Cancelled Folder". Please advise.
I have a code which I already use. it needs some modification. Please help me with this.
I'm finding it difficult to change this code to read the subject line and move the mail
Whenever I reply from the "In Progress Folder" I will add a keyword to the Subject line. if the I add Completed in the Subject line that mail has to move to "Completed Folder" and Whenever I reply from the "In Progress Folder" and if the I add a word Cancelled in the Subject line that mail has to moved to "Cancelled Folder". Please advise.
I have a code which I already use. it needs some modification. Please help me with this.
I'm finding it difficult to change this code to read the subject line and move the mail
If InStr(1, Item.Subject, olObj.Subject) > 0
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olNameSpace As NameSpace
Set olNameSpace = GetNamespace("MAPI")
Dim olDestFolder As Folder
Set olDestFolder = olNameSpace.Folders("xxxx.com").Folders("Completed")
Dim olDestFolder1 As Folder
Set olDestFolder1 = olNameSpace.Folders("xxxx.com").Folders("Cancelled")
Dim olLookUpFolder As Folder
Set olLookUpFolder = olNameSpace.Folders("xxx.com").Folders("In Progress")
' olMail is a Class. Avoid as a variable name
'Dim olMail As MailItem
Dim olObj As Object ' Outlook items are not necessarily mailitems
For Each olObj In olLookUpFolder.Items 'loop through Tickets folder to find original mail
If olObj.Class = olMail Then
If InStr(1, Item.Subject, olObj.Subject) > 0 Then 'look for olObj.Subject in Item.Subject
olObj.Move olDestFolder ' move to InProgress folder
Exit For
End If
End If
Next
End Sub