A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

ItemAdd event not functioning - not triggering.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 18th 10, 06:37 PM posted to microsoft.public.outlook.program_vba
BlueWolverine
external usenet poster
 
Posts: 7
Default ItemAdd event not functioning - not triggering.

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  
Old May 18th 10, 09:55 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default ItemAdd event not functioning - not triggering.

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 08:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.