Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Change Flagststus in Outlook using VBA

Status
Not open for further replies.

ChrisSee

Programmer
Jun 12, 2003
1
GB
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top