Changing NoAging flag in function of the FlagIcon property


Joined
Feb 1, 2006
Messages
2
Reaction score
0
Hi there,

i'm quite new to Microsoft Outlook VB programming, and don't even know if it is possible what i want to do.
Since some time, I'm working with the colored flags to keep track of things still to do, put on hold, ... I autoarchive each month, since I'm connected to an Exchange Server where the storage limit is quite low. When archiving, I want however to keep the flagged mails in my exchange mailbox. To do this, I allready found out how to put the NoAging flag.


I can't find out however how to automate this, meaning:

- when flagging (colored) an email, the NoAging flag should be set to True

- when flagging the email complete, the NoAging flag should be reset to False



This way I can automate this instead of running manually a script each time before Archiving.



Any help would be appreciated,

Kind regards, NiceGuy
 
Ad

Advertisements

Joined
Feb 1, 2006
Messages
2
Reaction score
0
Hi, I found the solution (after a long night :)) myself.
Code:
Private WithEvents myOlInboxItems As Outlook.Items
Private WithEvents myOlSentItems As Outlook.Items
 
Private Sub Application_Startup()
	'MsgBox "Hi there, welcome to Outlook"
	Set myOlInboxItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
	Set myOlSentItems = Outlook.Session.GetDefaultFolder(olFolderSentMail).Items
End Sub
 
Private Sub myOlInboxItems_ItemChange(ByVal Item As Object)
	'See if its a MailItem
	If TypeName(Item) = "MailItem" Then
		Dim MI As MailItem
		Set MI = Item
 
		' MsgBox "Email item olFlagStatus Value: " & Str(MI.FlagStatus)
		If MI.FlagStatus = olFlagComplete Then
			MI.NoAging = False
		ElseIf MI.FlagStatus = olFlagMarked Then
			MI.NoAging = True
		ElseIf MI.FlagStatus = olNoFlag Then
			MI.NoAging = False
		End If
 
		Set MI = Nothing
 
	End If
End Sub
 
Private Sub myOlSentItems_ItemChange(ByVal Item As Object)
	'See if its a MailItem
	If TypeName(Item) = "MailItem" Then
		Dim MI As MailItem
		Set MI = Item
 
		' MsgBox "Email item olFlagStatus Value: " & Str(MI.FlagStatus)
		If MI.FlagStatus = olFlagComplete Then
			MI.NoAging = False
		ElseIf MI.FlagStatus = olFlagMarked Then
			MI.NoAging = True
		ElseIf MI.FlagStatus = olNoFlag Then
			MI.NoAging = False
		End If
 
		Set MI = Nothing
 
	End If
End Sub
The only problem I still have is that I have to create this Procedure for each folder where I modify this flag (being Inbox, Sent Items, my 'Unread' Search Folder, ...
Is there a way to group all of them and to implement this procedure only once for all folders?

Kind regards,
NiceGuy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top