-----Original Message-----
Cindy-
I can think of 2 approaches here to marking the e-mails.
The first is to use one of the hidden properties: 'Billing
Information' (that's one word) or 'Mileage'. This is
probably not the best approach, though, as it requires
significantly more work.
The other, simpler approach, which I would recommend,
would be to use Categories to mark the e-mails when
everyone is done working with them. Simply add a Category
through the user interface - click on the 'Categories'
button in any open Contact, type in a name for the new
Category, such as "Processed" or "Done", and click 'Add to
List'.
Then, when the users are finished working with the e- mail,
they add it to the "Processed" Category (or whatever you
called it). This can be done by right-clicking the e- mail,
choosing 'Categories', and selecting the appropriate one-
or, you could add a button to the toolbar to pull the
Categories dialog up; that's probably the better way.
Finally, your code would need to iterate through the
mailbox, checking each item for the presence of the
appropriate Category, and then moving the marked e-mails.
You could use code like this to find the marked e-mails:
'***********[ BEGIN CODE ]************
' change value of constant to name you chose:
Const strCATEGORY As String = "Processed"
Dim itmItems As Items
Dim itmMailItem As Object
Dim ol As Outlook.Application
Dim olns As Outlook.NameSpace
Dim MyFolder
' if mailbox is REALLY large, change next var. to Long:
Dim i As Integer ' holds # of marked mails we found
Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set MyFolder = olns.GetDefaultFolder(olFolderInbox)
Set itmItems = MyFolder.Items
For Each itmMailItem In itmItems
If itmMailItem.Class = olMail Then
If InStr(itmMailItem.Categories, strCATEGORY) > 0 Then
' CODE TO ...
' MOVE MAIL ITEM ...
' GOES HERE
i = i + 1
End If
End If
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description & vbCrLf & _
"Mail item Sender: " & itmMailItem.Subject & vbCrLf & _
"Mail item Subject: " & itmMailItem.Subject
End If
Next
If Err.Number = 0 Then
' Announce success, & how many items moved:
MsgBox i & " Items moved successfully."
End If
Set ol = Nothing
Set olns = Nothing
Set MyFolder = Nothing
Set itmItems = Nothing
'*************[ END CODE ]*************
Please note a few things about the above code:
-I have left the coding for actually moving the e-mails to
another folder, to you. Look in the Outlook VBA Help for
the 'Move' method, which you can use on a mail item.
-You must change the value of the Constant to the name of
the Category you created.
-If you're using this code from another App or from Visual
Basic, you must set a Reference to the Outlook Object
Library.
-If the e-mails you want to process are not directly in
the Inbox, but are in a sub-folder under the inbox, you
must use a line like this:
Set MyFolder = olNameSpace.GetDefaultFolder
(olFolderInbox).Folders(strMyMailFolder)
' [that's all one line, no spaces]
instead of this line:
Set MyFolder = olns.GetDefaultFolder(olFolderInbox)
and: strMyMailFolder must be a string holding the actual
name of the folder your mail is in. You will need to do
additional coding if your folder is not directly under the
inbox, but is a sub-folder of a sub-folder in the Inbox.
As to where to put the code, & when to run it: you have a
few options here. You could put the code into a module and
add a toolbar button to run it manually; you could call it
from an Outlook Application Event, such as NewMail() or
ItemSend.
Or, possibly the best approach: trap the Inspector_Close ()
event, test to see whether the Item is a MailItem, & if
so, run the code on that item- you would not use the
looping code in that situation. Instead, you run the code
on the current item.
Perhaps someone else has a better solution I'm overlooking?
For info on distributing the code to your co-workers, see
http://support.microsoft.com/?kbid=229911 .
Anyway, that should be enough to get you started.
-Andrew Cushen
===============================================
-----Original Message-----
Hi,
I have a mailbox that many users will be sending emails to
and about 5 "admin staff" that will be handling the email
requests in the same mailbox. I need a method of deleting
the emails or moving them to a different folder
(processed) based on the admin staff somehow marking the
email as "done". This is to prevent the same email being
processed by more than one admin staff member.
Any ideas? I'm new to Outlook coding but have done vba
coding in Excel and Access.
Thank you
Cindy
.
.