Hello,
I am trying to copy flagged items in outlook to another folder and then change the falgged status to noflag or even complete. This is the code that I am using
Sub CopyFlaggedItems()
Set myOlApp = CreateObject("Outlook.Application"
Set mynamespace = myOlApp.GetNamespace("MAPI"
Set Myfolder = mynamespace.GetDefaultFolder(olFolderInbox)
Set objsourceFolder = Myfolder
Set objns = Application.GetNamespace("MAPI"
Set oInboxItems = objsourceFolder.Items
Set mystore = mynamespace.Folders(2)
Set objTargetFolder = mystore.Folders(2)
iNumItems = oInboxItems.Count
For I = iNumItems To 1 Step -1
Set objcuritem = oInboxItems.Item(I)
If TypeName(objcuritem) = "MailItem" Then
'MsgBox status1 ' Move only mail messages
If objcuritem.FlagStatus = 2 Then
Set myCopiedItem = objcuritem.Copy
myCopiedItem.Move objTargetFolder
objcuritem.FlagStatus = (1)
End If
End If
Next
End Sub
Everything works with the copy but I do not seem to be able to change the flag status. using objcuritem.FlagStatus = (0)
or objcuritem.FlagStatus = OlnoFlag
Anyone have any tips as to what I am doing wrong.
I am trying to copy flagged items in outlook to another folder and then change the falgged status to noflag or even complete. This is the code that I am using
Sub CopyFlaggedItems()
Set myOlApp = CreateObject("Outlook.Application"
Set mynamespace = myOlApp.GetNamespace("MAPI"
Set Myfolder = mynamespace.GetDefaultFolder(olFolderInbox)
Set objsourceFolder = Myfolder
Set objns = Application.GetNamespace("MAPI"
Set oInboxItems = objsourceFolder.Items
Set mystore = mynamespace.Folders(2)
Set objTargetFolder = mystore.Folders(2)
iNumItems = oInboxItems.Count
For I = iNumItems To 1 Step -1
Set objcuritem = oInboxItems.Item(I)
If TypeName(objcuritem) = "MailItem" Then
'MsgBox status1 ' Move only mail messages
If objcuritem.FlagStatus = 2 Then
Set myCopiedItem = objcuritem.Copy
myCopiedItem.Move objTargetFolder
objcuritem.FlagStatus = (1)
End If
End If
Next
End Sub
Everything works with the copy but I do not seem to be able to change the flag status. using objcuritem.FlagStatus = (0)
or objcuritem.FlagStatus = OlnoFlag
Anyone have any tips as to what I am doing wrong.