![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hello,
MS OUTLOOK 2003 on XP PRO. What I'm trying to do: I want to take every email I send, move it to a PST folder, and mark as read using VBA since this isn't possible in a rule (specifically mark as read). My Problem: Through this forum and some other places, I think I have code that's at least close to doing this. The problem is, the darn thing never triggers. Please help me with this code. Thank you. All of what follows is the entirety of a class module. Dim myolApp As New Outlook.Application Public WithEvents myOlItems As Outlook.Items Public Sub Initialize_handler() Set myOlItems = myolApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderSentMail).Items End Sub Public Sub myOlItems_ItemAdd(ByVal Item As Object) Dim myInbox As Outlook.MAPIFolder Dim myFolder As Outlook.MAPIFolder Dim myNewFolder As Outlook.MAPIFolder Set myFolder = myNameSpace.GetDefaultFolder(olFolderSentMail) Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox) Set myNewFolder = myInbox.Folders("EMAIL") Item.Move myNewFolder Item.UnRead = False Item.Save Debug.Print Item.Subject End Sub -- BlueWolverine MSE - Mech. Eng. Go BLUE! |
Ads |
#2
|
|||
|
|||
![]()
First things first. If this is running in the Outlook VBA project use the
intrinsic, trusted Application object. Don't use New. If the code is in a class then are you instantiating an instance of the class and calling the init code? Usually you'd put the code in the ThisOutlookSession class, which is automatically instantiated. Then you'd call your init handler code from the Application_Startup() event handler, which is automatically available in ThisOutlookSession. -- 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 "BlueWolverine" wrote in message ... Hello, MS OUTLOOK 2003 on XP PRO. What I'm trying to do: I want to take every email I send, move it to a PST folder, and mark as read using VBA since this isn't possible in a rule (specifically mark as read). My Problem: Through this forum and some other places, I think I have code that's at least close to doing this. The problem is, the darn thing never triggers. Please help me with this code. Thank you. All of what follows is the entirety of a class module. Dim myolApp As New Outlook.Application Public WithEvents myOlItems As Outlook.Items Public Sub Initialize_handler() Set myOlItems = myolApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderSentMail).Items End Sub Public Sub myOlItems_ItemAdd(ByVal Item As Object) Dim myInbox As Outlook.MAPIFolder Dim myFolder As Outlook.MAPIFolder Dim myNewFolder As Outlook.MAPIFolder Set myFolder = myNameSpace.GetDefaultFolder(olFolderSentMail) Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox) Set myNewFolder = myInbox.Folders("EMAIL") Item.Move myNewFolder Item.UnRead = False Item.Save Debug.Print Item.Subject End Sub -- BlueWolverine MSE - Mech. Eng. Go BLUE! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ItemAdd event fires more than once when adding a new appointment | Johan Machielse[_2_] | Add-ins for Outlook | 1 | July 22nd 08 01:11 PM |
(VSTO SE) folder.Items.ItemAdd Event does not fire | David | Outlook and VBA | 5 | March 7th 07 09:41 PM |
ItemAdd in Deleted Items event doesnt fire after a while | [email protected] | Add-ins for Outlook | 11 | January 8th 07 09:27 AM |
ItemAdd in Deleted Items event doesnt fire after a while | SHUperb | Outlook - Calandaring | 0 | January 5th 07 08:41 AM |
ItemAdd event with Outlook2007 | DavidH&P | Outlook - Using Forms | 2 | July 4th 06 09:29 AM |