| Code level: beginner Code area: Basic Outlook Printer Friendly Version | ||
| Title: ItemAdd event handler to monitor Sent Items folder | ||
| Description: This sample demonstrates how to monitor the Sent Items folder and display the Categories dialog for each item sent (Outlook 2002 or later only). You could use the same framework to copy or move sent messages into different folders or perform other operations on them. | ||
| Date: 17-Jun-2004 01:38 | ||
| Code level: beginner | ||
| Code area: Basic Outlook | ||
| Posted by: Sue Mosher | ||
| Body: |
||
| All 71comments |
| Page [ 1 2 3 4 5 6 7 8 Next >> ] | ||
|
|
alini76
20-Jun-2004 16:58
Hi Sue ! Why is Item.Save needed... Actually the story is that I wrote a COM Add-In. On OL2003 after I move an MailItem to another folder, I cannot move it after that. For example, I have Item X and I move it to folder Y. I get to folder Y, and I try to move item X to folder Z. The last operation doesn't work anymore. My COM Add-In records the behavior of a user(forward, reply, reply all, move, move to deleted folder, open ,close) Thank you, Alin |
|
|
|
Sue Mosher
20-Jun-2004 17:36
You need Item.Save if, as in this example, you're changing the item after it's already been added to the folder. The situation you describe doesn't sound related to Save at all. I'd suggest that you start a new discussion on that topic and post the relevant code snippet. |
|
|
|
Sue Mosher
23-Jun-2004 16:01
To use the MAPIFolder.Items.ItemAdd event with a non-default folder, you need to walk the folder hierarchy using the Folders collections to return the MAPIFolder or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm |
|
|
|
Erik
19-Aug-2004 09:02
This looks like something i could use since i want to be able to move mails from my sent-mail to another users sent-mail if i send mails for him. I found a .dll but that will be way to expensive to use in our company. How do i use the code above, it shouldnt be so hard to modify it to suit my needs, or?! :) |
|
|
|
Sue Mosher
19-Aug-2004 17:48
You add the code to the built-in ThisOutlookSession module in Outlook VBA. If you're new to Outlook VBA macros, these web pages should help you get started: http://www.winnetmag.com/Articles/Index.cfm?ArticleID=21522&pg=1 http://www.outlookcode.com/d/vb.htm |
|
|
|
Anonymous
13-Feb-2005 15:51
What happens if there are 10 emails in the outbox, it seems that colSentItems_ItemAdd only gets one event, How can I get all 10 ? |
|
|
|
Sue Mosher
14-Feb-2005 08:32
ItemAdd may not fire if many items arrive in the folder at once. A workaround would be to process the Item that ItemAdd passes as an argument and mark that item as processed, maybe in the Mileage property. Then process any other unmarked items in the folder. |
|
|
|
Sue Mosher
25-Feb-2005 09:43
Another application of this basic technique would be to change the message class of items arriving in a folder so that they'll display in a different custom form. If you wanted, for example, to change the class of appointments that you accept from meeting requests, you'd need to get the Calendar folder, not the Sent Items folder, and so GetDefaultFolder would need a different argument: Set colSentItems = NS.GetDefaultFolder(olFolderCalendar).Items Note that the name of the object declared WithEvents doesn't really matter. If you want to change it to colCalendar, then you'd need to make that change everywhere in the module. To change the message class for newly added appointments, you'd make sure you have an actual appointment, change the class, then save the item: If Item.Class = olAppointment Then Item.MessageClass = "IPM.Appointment.MyForm" Item.Save End If |
|
|
|
kakubo
28-Mar-2006 07:50
thanks , this code really can help me a lot. |
|
|
|
kakubo
28-Mar-2006 10:58
i tried tried setting the mileage property for all the incoming mails. It woks. But i have to set to set it to search through the whole inbox folder and skipped through all those mark "processed". Is there a better way? because if the inbox is big and store on a network drive, the "search-through-whole-mailbox" process is going to take some time. |
|
| Page [ 1 2 3 4 5 6 7 8 Next >> ] | ||
| Post your comment name email |
