 |
|
|
|
| Author |
Message |
delfino.nunez
Joined: 19 Feb 2008 Posts: 6
|
Posted: Tue Feb 19, 2008 1:01 pm Post subject: Get outlook post item flag value |
|
|
Does anyone knows how to get the property FLAGICON from a post item.
something like this
If mpfInbox.Items(1).Class = olPost Then
MsgBox mpfInbox.Items(1).FlagIcon
End If
But not for olMailItem, should be for the Posts.
I need to move POSTS from one folder to another based on the flag
color.
For example, only post with green and completed flag will be moved to
another folder.
Thanks for your help
Archived from group: microsoft>public>office>developer>outlook>vba |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo
Joined: 12 Aug 2007 Posts: 405
|
Posted: Tue Feb 19, 2008 4:49 pm Post subject: Re: Get outlook post item flag value |
|
|
It's not exposed in the Outlook object model, you'd have to use a lower
level API such as Extended MAPI (C++ or Delphi only) or CDO 1.21 or a 3rd
party library such as Redemption (www.dimastr.com/redemption).
Using those API's you would access the property PR_FLAG_ICON (0x10950003).
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
wrote in message @e10g2000prf.googlegroups.com...
> Does anyone knows how to get the property FLAGICON from a post item.
> something like this
>
> If mpfInbox.Items(1).Class = olPost Then
> MsgBox mpfInbox.Items(1).FlagIcon
> End If
>
> But not for olMailItem, should be for the Posts.
>
> I need to move POSTS from one folder to another based on the flag
> color.
> For example, only post with green and completed flag will be moved to
> another folder.
>
>
> Thanks for your help |
|
| Back to top |
|
 |
delfino.nunez
Joined: 19 Feb 2008 Posts: 6
|
Posted: Tue Feb 19, 2008 2:08 pm Post subject: Re: Get outlook post item flag value |
|
|
I will take a look to those API's.
Thanks Ken.
On Feb 19, 11:49 am, "Ken Slovak - [MVP - Outlook]"
wrote:
> It's not exposed in theOutlookobject model, you'd have to use a lower
> level API such as Extended MAPI (C++ or Delphi only) or CDO 1.21 or a 3rd
> party library such as Redemption (www.dimastr.com/redemption).
>
> Using those API's you would access the property PR_FLAG_ICON (0x10950003).
>
> --
> Ken Slovak
> [MVP -Outlook]http://www.slovaktech.com
> Author: Professional ProgrammingOutlook2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
> |
|
| Back to top |
|
 |
delfino.nunez
Joined: 19 Feb 2008 Posts: 6
|
Posted: Tue Feb 19, 2008 4:55 pm Post subject: Re: Get outlook post item flag value |
|
|
Hi Ken,
I'm new to creating macros for outlook. I tried to access the property
but I'm not able to do it. Here is what I've done:
Sub cleanmtl()
Set Folder = Session.Folders("Public Folders").Folders("All Public
Folders")
Set Items = Folder.Items
Set Mail = Items.Item(2)
MsgBox Mail.Subject & " - from: " & Mail.SenderName
&Mail.PR_FLAG_ICON
End Sub
Also this one
Sub old3CleanMTLDBA()
Set Application = CreateObject("Outlook.Application")
Set NameSpace = Application.GetNamespace("MAPI")
Set mpfInbox = Session.Folders("Public Folders").Folders("All Public
Folders")
Set Application.ActiveExplorer.CurrentFolder = Session.Folders("Public
Folders").Folders("All Public Folders")
Dim SafePostItem, oPostItem
Set SafePostItem = CreateObject("Redemption.SafePostItem")
Set oPostItem = mpfInbox.Items(4)
SafePostItem.Item = oPostItem
MsgBox SafePostItem.PR_FLAG_ICON
End Sub
I know I'm doing something wrong but not sure where is it or how can I
access the property.
Thanks a lot for your help
On Feb 19, 11:49 am, "Ken Slovak - [MVP - Outlook]"
wrote:
> It's not exposed in theOutlookobject model, you'd have to use a lower
> level API such as Extended MAPI (C++ or Delphi only) or CDO 1.21 or a 3rd
> party library such as Redemption (www.dimastr.com/redemption).
>
> Using those API's you would access the property PR_FLAG_ICON (0x10950003).
>
> --
> Ken Slovak
> [MVP -Outlook]http://www.slovaktech.com
> Author: Professional ProgrammingOutlook2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> wrote in message
>
> @e10g2000prf.googlegroups.com...
>
> > Does anyone knows how to get the property FLAGICON from apostitem.
> > something like this
>
> > If mpfInbox.Items(1).Class = olPost Then
> > MsgBox mpfInbox.Items(1).FlagIcon
> > End If
>
> > But not for olMailItem, should be for the Posts.
>
> > I need to move POSTS from one folder to another based on the flag
> > color.
> > For example, onlypostwith green and completed flag will be moved to
> > another folder.
>
> > Thanks for your help |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo
Joined: 12 Aug 2007 Posts: 405
|
Posted: Tue Feb 19, 2008 8:37 pm Post subject: Re: Get outlook post item flag value |
|
|
PR_FLAG_ICON is a long value, in the case of Red flag it's value is 6. It's
an optional property, it's only there if the item is flagged. And as I said,
it's not available from the Outlook object model at all.
Taking your second example, the one using Redemption code:
Sub old3CleanMTLDBA()
Set Application = CreateObject("Outlook.Application")
Set NameSpace = Application.GetNamespace("MAPI")
Set mpfInbox = Session.Folders("Public Folders").Folders("All Public
Folders")
Set Application.ActiveExplorer.CurrentFolder = Session.Folders("Public
Folders").Folders("All Public Folders")
Dim SafePostItem, oPostItem
Cont PR_FLAG_ICON = &H10950003
Set SafePostItem = CreateObject("Redemption.SafePostItem")
' this assumes # 4 item in that Items collection is really a Post item
Set oPostItem = mpfInbox.Items(4)
SafePostItem.Item = oPostItem
If Not(IsEmpty(SafePostItem.Fields(PR_FLAG_ICON)) Then
MsgBox SafePostItem.Fields(PR_FLAG_ICON)
Else
MsgBox "Item has no flag icon assigned"
End If
End Sub
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
wrote in message @q70g2000hsb.googlegroups.com...
> Hi Ken,
> I'm new to creating macros for outlook. I tried to access the property
> but I'm not able to do it. Here is what I've done:
> Sub cleanmtl()
> Set Folder = Session.Folders("Public Folders").Folders("All Public
> Folders")
> Set Items = Folder.Items
> Set Mail = Items.Item(2)
> MsgBox Mail.Subject & " - from: " & Mail.SenderName
> &Mail.PR_FLAG_ICON
> End Sub
>
> Also this one
>
> Sub old3CleanMTLDBA()
> Set Application = CreateObject("Outlook.Application")
> Set NameSpace = Application.GetNamespace("MAPI")
> Set mpfInbox = Session.Folders("Public Folders").Folders("All Public
> Folders")
> Set Application.ActiveExplorer.CurrentFolder = Session.Folders("Public
> Folders").Folders("All Public Folders")
>
> Dim SafePostItem, oPostItem
> Set SafePostItem = CreateObject("Redemption.SafePostItem")
> Set oPostItem = mpfInbox.Items(4)
>
> SafePostItem.Item = oPostItem
> MsgBox SafePostItem.PR_FLAG_ICON
> End Sub
>
> I know I'm doing something wrong but not sure where is it or how can I
> access the property.
>
> Thanks a lot for your help |
|
| Back to top |
|
 |
delfino.nunez
Joined: 19 Feb 2008 Posts: 6
|
Posted: Thu Feb 21, 2008 2:02 pm Post subject: Re: Get outlook post item flag value |
|
|
Thanks for your help Ken, it worked very well. Here is the code I
made, works for what I wanted and maybe is not very efficient but it
does the job.
Again thanks for the tips.
Public Sub CleanMTLDBA()
'===================================================
'VALUES FOR CONSTANTS
'
'*PR_FLAG_ICON
'
'RED=6
'BLUE=5
'YELLOW=4
'GREEN=3
'ORANGE=2
'PURPLE=1
'
'*PR_FLAG_STATUS
'
'CHECKED COMPLETE=1
'WITH FLAG COLOR=2
'===================================================
Dim SafePostItem, oPostItem
Dim NumItems
Dim response
Set Application = CreateObject("Outlook.Application")
Set NameSpace = Application.GetNamespace("MAPI")
Set mpfInbox = Session.Folders("Public Folders").Folders("All Public
Folders").Folders("ALL")
'folder locations
Set bmcFldr = Session.Folders("Public Folders").Folders("All Public
Folders").Folders("BMC")
Set backupAllFldr = Session.Folders("Public Folders").Folders("All
Public Folders").Folders("Backup")
Const PR_FLAG_ICON = &H10950003
Const PR_FLAG_STATUS = &H10900003
Set SafePostItem = CreateObject("Redemption.SafePostItem")
itemsMoved = 0
For Each Item In mpfInbox.Items
Set oPostItem = Item
SafePostItem.Item = oPostItem
lBody = LCase$(SafePostItem.Body)
lSubject = LCase$(SafePostItem.Subject)
'if the flag is set to any color or checked complete then move the
item
If (Not (IsEmpty(SafePostItem.Fields(PR_FLAG_ICON))) Or
SafePostItem.Fields(PR_FLAG_STATUS) = 1) Then
'move the item when the flag is green(3) or is check complete(1)
If (SafePostItem.Fields(PR_FLAG_ICON) = 3 Or
SafePostItem.Fields(PR_FLAG_STATUS) = 1) Then
'BMC
If InStr(lSubject, "bmc") 0 Then
oPostItem.Move bmcFldr
itemsMoved = itemsMoved + 1
'Backup All
ElseIf (InStr(SafePostItem.SenderName, "Data Protector") 0
Or _
InStr(lBody, "squidly") 0) Then
oPostItem.Move backupAllFldr
itemsMoved = itemsMoved + 1
End If '===IF ELSE/CASE
End If '=== Check if the flag is green or complete
End If '=== Check if the flag is set to color or complete
Next Item
MsgBox "Total Messages Moved: " & itemsMoved, vbInformation, "Finished
Moving"
End Sub |
|
| Back to top |
|
 |
Dmitry Streblechenko
Joined: 12 Aug 2007 Posts: 220
|
Posted: Thu Feb 21, 2008 3:11 pm Post subject: Re: Get outlook post item flag value |
|
|
Do not Move/Delete items in a "for each" or "for i=1 to Count" loop as you
are changing the total items count, so you will skip some items.
Loop Count to 1 step -1 instead.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
wrote in message @e60g2000hsh.googlegroups.com...
> Thanks for your help Ken, it worked very well. Here is the code I
> made, works for what I wanted and maybe is not very efficient but it
> does the job.
> Again thanks for the tips.
>
> Public Sub CleanMTLDBA()
>
> '===================================================
> 'VALUES FOR CONSTANTS
> '
> '*PR_FLAG_ICON
> '
> 'RED=6
> 'BLUE=5
> 'YELLOW=4
> 'GREEN=3
> 'ORANGE=2
> 'PURPLE=1
> '
> '*PR_FLAG_STATUS
> '
> 'CHECKED COMPLETE=1
> 'WITH FLAG COLOR=2
> '===================================================
>
> Dim SafePostItem, oPostItem
> Dim NumItems
> Dim response
>
> Set Application = CreateObject("Outlook.Application")
> Set NameSpace = Application.GetNamespace("MAPI")
> Set mpfInbox = Session.Folders("Public Folders").Folders("All Public
> Folders").Folders("ALL")
>
> 'folder locations
> Set bmcFldr = Session.Folders("Public Folders").Folders("All Public
> Folders").Folders("BMC")
> Set backupAllFldr = Session.Folders("Public Folders").Folders("All
> Public Folders").Folders("Backup")
>
> Const PR_FLAG_ICON = &H10950003
> Const PR_FLAG_STATUS = &H10900003
>
> Set SafePostItem = CreateObject("Redemption.SafePostItem")
>
> itemsMoved = 0
>
>
> For Each Item In mpfInbox.Items
> Set oPostItem = Item
> SafePostItem.Item = oPostItem
> lBody = LCase$(SafePostItem.Body)
> lSubject = LCase$(SafePostItem.Subject)
>
> 'if the flag is set to any color or checked complete then move the
> item
> If (Not (IsEmpty(SafePostItem.Fields(PR_FLAG_ICON))) Or
> SafePostItem.Fields(PR_FLAG_STATUS) = 1) Then
>
> 'move the item when the flag is green(3) or is check complete(1)
> If (SafePostItem.Fields(PR_FLAG_ICON) = 3 Or
> SafePostItem.Fields(PR_FLAG_STATUS) = 1) Then
>
> 'BMC
> If InStr(lSubject, "bmc") 0 Then
> oPostItem.Move bmcFldr
> itemsMoved = itemsMoved + 1
>
> 'Backup All
> ElseIf (InStr(SafePostItem.SenderName, "Data Protector") 0
> Or _
> InStr(lBody, "squidly") 0) Then
> oPostItem.Move backupAllFldr
> itemsMoved = itemsMoved + 1
>
> End If '===IF ELSE/CASE
>
> End If '=== Check if the flag is green or complete
> End If '=== Check if the flag is set to color or complete
> Next Item
>
> MsgBox "Total Messages Moved: " & itemsMoved, vbInformation, "Finished
> Moving"
> End Sub
>
>
>
> |
|
| Back to top |
|
 |
delfino.nunez
Joined: 19 Feb 2008 Posts: 6
|
Posted: Thu Feb 21, 2008 3:58 pm Post subject: Re: Get outlook post item flag value |
|
|
Thanks for the tip Dmitry, I'll do the change.
One question, do you know if there is an easy way (outlook scripting)
to show a progress bar or the progress of the script in a window,
without installing components, just using what's in outlook?
Thanks again! |
|
| Back to top |
|
 |
Dmitry Streblechenko
Joined: 12 Aug 2007 Posts: 220
|
Posted: Thu Feb 21, 2008 9:02 pm Post subject: Re: Get outlook post item flag value |
|
|
Can't do that without having your own window with a progress bar...
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
wrote in message @k2g2000hse.googlegroups.com...
> Thanks for the tip Dmitry, I'll do the change.
> One question, do you know if there is an easy way (outlook scripting)
> to show a progress bar or the progress of the script in a window,
> without installing components, just using what's in outlook?
>
> Thanks again! |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo
Joined: 12 Aug 2007 Posts: 405
|
Posted: Fri Feb 22, 2008 1:47 pm Post subject: Re: Get outlook post item flag value |
|
|
It's not an easy way but without 3rd party components or a VB progress
control you could do something like putting 25 little squares on a VBA
UserForm, maybe picture box controls that show just a small colored square
image. Then your code could make them visible in turn to simulate a progress
control. Lots of work for minimal return I think.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Dmitry Streblechenko" wrote in message @TK2MSFTNGP05.phx.gbl...
> Can't do that without having your own window with a progress bar...
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> wrote in message
> @k2g2000hse.googlegroups.com...
>> Thanks for the tip Dmitry, I'll do the change.
>> One question, do you know if there is an easy way (outlook scripting)
>> to show a progress bar or the progress of the script in a window,
>> without installing components, just using what's in outlook?
>>
>> Thanks again!
>
> |
|
| Back to top |
|
 |
delfino.nunez
Joined: 19 Feb 2008 Posts: 6
|
Posted: Fri Feb 22, 2008 11:15 am Post subject: Re: Get outlook post item flag value |
|
|
Yes it doesn't make sense to do a lot of work for so little and I
don't want to make it to complicated.
Thanks for all your help guys.
|
|
| Back to top |
|
 |
|
|
| Related Topics: | Newbie "save post item as .." Can't get it to work. I can't get this macro to work. i'm trying to save the email item that is open to a file. I'm trying two alternatives, i.e., save to .txt and save to .html Nothing gets saved, when I use the code line below strname & ".txt", olTXT") and
set sent flag Hi Group! I am trying to auto-archive mails based on an user input - so if the user types the number of a project the mails is automatically copied to a public folder for this project. My Problem is, that copying with the outlook object model does not set
flag messages that my email is as CC Dear all I get plenty of email messages during the day. I was wondering if someone can offer an advice to somehow flag with a different colour or maybe moove to a diferent folder messages that my email address is as CC in. Like lets say colour with green
Script/macro to change subject and flag messages Hi. I have a question about a script/macro that I want to create. The thing is that it's at a Helpdesk where a number of agents work against the same mailbox, where user send ther questions and quereis. To designate that an agent is working on the case, t
Delete a post from this newsgroup? How does one delete a posting from this newsgroup? I recently posted a question and stupidly listed my name and email address, foolishly assuming only people of integrity used this forum. Instead, I have been swamped with Spam that purports to be from Mi |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|