• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Outlook VBA set flag

I can read the emails, so I know oItem is set correctly.
I cannot find a way to set a flag or anything else for the particular emails
I have Outlook 2010.


 For Each oItem In oFolder.Items
    If InStr(oItem.Subject, "Information about your order (#") > 0 Then
        oItem.FlagRequest = "Follow up"
    end if
 Next

Open in new window

0
rrhandle8
Asked:
rrhandle8
  • 6
  • 3
  • 2
  • +1
2 Solutions
 
ReneD100Commented:
not 100% sure, but try this:
For Each oItem In oFolder.Items
    If InStr(oItem.Subject, "Information about your order (#") > 0 Then
        oItem.FlagRequest = "Follow up"
        oItem.FlagStatus = olFlagMarked           'olNoFlag / olFlagComplete are also available
    end if
 Next

Open in new window

0
 
Alexei Kuznetsov (Outlook MVP)CEOCommented:
FlagRequest is a text property that specifies the text associated with a flag. In order to enable the flag itself, you need to set the FlagStatus property. In addition, you can set FlagIcon property if needed:
olItem.FlagStatus = 2
olItem.FlagRequest = "Follow up"
olItem.FlagIcon = 6

Open in new window

FlagStatus can take the value of 0 (no flag), 1 (complete) or 2 (marked). See FlagIcon values on MSDN: http://msdn.microsoft.com/en-us/library/office/ff960469(v=office.15).aspx
0
 
Joshua GrantomSystems AdministratorCommented:
Also need to save.

 For Each oItem In oFolder.Items
    If InStr(oItem.Subject, "Information about your order (#") > 0 Then
        oItem.FlagStatus = 2
        oItem.FlagRequest = "Follow up"
        oItem.FlagIcon = 6
        oItem.Save
    end if
 Next

Open in new window

0
Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

 
rrhandle8Author Commented:
ReneD100 & thims,
I tried both suggestions.  Nothing.
0
 
rrhandle8Author Commented:
Maybe I defined it wrong

 Dim oNS As Outlook.NameSpace
 Dim oFolder As Outlook.MAPIFolder
 Dim oItem As Variant
0
 
rrhandle8Author Commented:
Set it to
 Dim oItem As mailItem
still nothing
0
 
Alexei Kuznetsov (Outlook MVP)CEOCommented:
Are you sure your
If InStr(oItem.Subject, "Information about your order (#") > 0 Then

Open in new window

condition is correct and works for your items? Try to MsgBox after this line to make sure it works. If not, try this:
InStr(1, olItem.Subject, "Information about your order (#", vbTextCompare)

Open in new window

0
 
rrhandle8Author Commented:
Oh yes.  It works. U did a F9 on the FlagStatus like to make sure.
0
 
Joshua GrantomSystems AdministratorCommented:
did you try oItem.Save from above?
0
 
rrhandle8Author Commented:
I did a F9 on the FlagStatus line to make sure.
0
 
rrhandle8Author Commented:
I missed the oItem.save Duh!
0
 
Joshua GrantomSystems AdministratorCommented:
glad to help!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now