Mark copy of sent email as read - VBA?

Mark copy of sent email as read - VBA?

Post by Qmx1ZVdvbH » Tue, 18 May 2010 21:41:01


Hello,
MS OUTLOOK 2003 on XP PRO.

I would like to setup a "rule" (either a "Rules Wizard" Rule or code in VBA)
to make a copy of every sent email, move it to a folder and mark that copy as
read. I did a search on google, and found the command "Item.Unread=false"
but I have no idea how to setup the code around it.

I hate asking, "Can someone show me how to do the entirety of what I'm
asking?" but I've never programmed in Outlook before and I have no idea how
to define an event trigger. (In access, I'd be looking for something like
"OnEmailSent") I have reasonably extensive experience programming in Excel
and Access but like I said I have no idea what to do in Outlook. If anyone
can give me a hand with this I'd be very grateful.

Thanks,
--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!
 
 
 

Mark copy of sent email as read - VBA?

Post by Michael Ba » Wed, 19 May 2010 15:46:28


The event you're looking for is the ItemAdd event of the folder for sent
items. That event fires when an item is added to the folder. There's an
example available in the VBA help file.

The added item is pased to the procedure, call its Copy function, which
returns a new item. For that you can call Move which returns the moved item.
For that call Unread=false, then Save.

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
< http://www.yqcomputer.com/ ;


Am Mon, 17 May 2010 05:41:01 -0700 schrieb BlueWolverine:

VBA)
as
how
Excel
anyone

 
 
 

Mark copy of sent email as read - VBA?

Post by Qmx1ZVdvbH » Wed, 19 May 2010 23:02:01

Thus far my code isn't even triggering. At least it's not failing or
corrupting my inbox but below is not triggering. All of the below code is in
a class module. Please help!

Initialize_handler

Dim myolApp As New Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
Set myOlItems =
myolApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal myItem 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") 'EMAIL is in a PST file.

myItem.Move myNewFolder
myItem.UnRead = False
myItem.Save

End Sub


--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!
 
 
 

Mark copy of sent email as read - VBA?

Post by Michael Ba » Thu, 20 May 2010 16:04:32


Put the code into the module ThisOutlookSession, and add this:

Private Sub Application_Startup()
Initialize_handler
end Sub

Application_Startup is the procedure called by Outlook at startup, and that
one's found only in ThisOutlookSession.

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
< http://www.yqcomputer.com/ ;

Am Tue, 18 May 2010 07:02:01 -0700 schrieb BlueWolverine:

in
file.