Srinevasand
Member
- Outlook version
- Outlook 2013 32 bit
- Email Account
- IMAP
All the reply (RE) and the forward (FWD) mails received in the shared inbox has to automatically move to an "Ongoing folder".
Code:
Private Sub Application_NewMail()
Dim olNameSpace As NameSpace
Set olNameSpace = GetNamespace("MAPI")
Dim olDestFolder As Folder
Set olDestFolder = olNameSpace.Folders("xxx@gmail.com").Folders("Ongoing")
Dim olLookUpFolder As Folder
Set olLookUpFolder = olNameSpace.Folders("xxx@gmail.com").Folders("Inbox")
' 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
Set objMail = objItem
v = objMail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10810003")
If (v = 102) Or (v = 104) Then
olObj.Move olDestFolder ' move to InProgress folder
Exit For
End If
End If
Next
End Sub