Is it possible to change the Flagstatus of emails moved to a folder in a shared mailbox?
Example: I receive a new mail and mark it with a red flag. Then, when the job is completed, I move the mail to the folder "Completed".
After moving the mail to this folder, I want the Flagstatus to be "olFlagComplete" (Green Flag) and every time I open Outlook, the code should check the folder for mails with red flag (e.g. Mails moved from mobile phone) and set it to green flag.
I tried the following, but nothing happened.
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olNameSpace As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Set olNameSpace = Application.GetNamespace("MAPI")
Set olFolder = olNameSpace.Folders("[email protected]")
Set olFolder = olFolder.Folders("Completed")
Set Items = olFolder.Items
End Sub
Private Sub Items_ItemChange(ByVal Item As Object)
Dim olNameSpace As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim Mail As MailItem
Set olNameSpace = Application.GetNamespace("MAPI")
Set olFolder = olNameSpace.Folders("[email protected]")
Set olFolder = olFolder.Folders("Completed")
If TypeOf Item Is Outlook.MailItem Then
Set Mail = Item
If Mail.FlagStatus = olFlagMarked Then
'Set ItemCopy = Item.Copy ' Copy Flagged item
'ItemCopy.Move olFolder ' Move Copied item
Set Mail.FlagStatus = olFlagComplete
End If
Set Item = Nothing
'Set ItemCopy = Nothing
End If
End Sub