Link to home
Start Free TrialLog in
Avatar of rrhandle8
rrhandle8Flag for United States of America

asked on

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

Avatar of ReneD100
ReneD100
Flag of Netherlands image

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

Avatar of Alexei Kuznetsov
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
SOLUTION
Avatar of Joshua Grantom
Joshua Grantom
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rrhandle8

ASKER

ReneD100 & thims,
I tried both suggestions.  Nothing.
Maybe I defined it wrong

 Dim oNS As Outlook.NameSpace
 Dim oFolder As Outlook.MAPIFolder
 Dim oItem As Variant
Set it to
 Dim oItem As mailItem
still nothing
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

Oh yes.  It works. U did a F9 on the FlagStatus like to make sure.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did a F9 on the FlagStatus line to make sure.
I missed the oItem.save Duh!
glad to help!