Macro to Mark Messages As Read

S

SP

This Damsel is Perplexed - A macro that when activated, will mark messages
as read. Using Outlook 2000, with the security setting as Medium. The
messages are sent via a Rule, utilizing Rules Wizard, the user has an email
with specific Text in the subject line, a copy is sent to a specific folder.
When they are sent to this folder it will mark the messages as unread. Is
there anyway to automate this so it happens automatically without using a
button.
Here is the code created for the automation:

private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

run macro = prjMarkAsRead.mcrMarkAsRead

End Sub
 
W

Woody

private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)

run macro = prjMarkAsRead.mcrMarkAsRead

-----------------------------------------------------------
in this outlook session
------------------------------------------------------------
Option Explicit

'set up outlook references
Dim outNameSpace As NameSpace

Public WithEvents OutItems As Outlook.Items

Private Sub outItems_ItemAdd(ByVal Item As Object)
On Error Resume Next

DoEvents
'make sure mail item in folder
If TypeName(Item) = "MailItem" Then
'set to read
With Item
.UnRead = false
.Save
End With

end sub
------------------------------------------------------------

rough draft but should be close

Woody
I am not responsible for anything you may see with my name attached to
it, i think.
 
P

Philip Brown

Hi, Sue,
I want to mark any message placed in my "Junk E-Mail"
folder as read. How do I do it?
I can't find anywhere on this newsgroup where this
question has been answered. Could you perhaps provide
that answer?

Thanks!

Philip Brown
 
S

s0lar1s8

Sub MarkRead()
'coded in outlook 2002
'some code taken from other usergroups, fyi
Dim app As New Outlook.Application
Dim ns As NameSpace
Set ns = app.GetNamespace("MAPI")
'Debug.Print ns.CurrentUser.Name
FindtoMark ns.Folders, 0
End Sub

Sub FindtoMark(parent As Folders, depth As Integer)
Dim flr As MAPIFolder
Dim s As String
s = String(depth * 2, " ")
For Each flr In parent
'Debug.Print s; flr.Name; ": "; flr.DefaultMessageClass;

'mark all as read in a particular folder.
If flr.Name = "Your folder name" Then
For Each objMailItem In flr.Items
'If objMailItem.SenderName = "Spammer Name" Then

If objMailItem.UnRead = True Then
objMailItem.UnRead = False
End If
'End If
Next
End If
ListFolder flr.Folders, depth + 1
DoEvents
Next flr

End Sub
 
D

docfknx

This is GREAT! Now how do you get it to auto-run everytime you get mail?
Or get mail in the specified folder?

Thanks!

Doc
 
D

docfknx

Actually it's simpler than I thought:

Sub Application_NewMail()
MarkRead
End Sub

Thanks again!

Doc
 
R

rpfields

Hi!

I am new to VBA Macros. I'd like to implement this in my Outlook 2000
I have no idea how to do so? Could anyone give me step by ste
instructions. Thank you!

Rega
 
T

TurboBeagle

(1) On your menu bar, go to tool...macros
(2) In the text box for macro name, type in "MarkRead" (without th
quotation marks.)
(3) Push the "create" button
(4) Paste the code from above straight into the vba editor.
(5) Type in the folder name from "Your Folder Name" to whatever th
real name of the folder is.

fyi, you can access multiple folders in the same module with the code

If flr.Name = "Your Folder Name" Or flr.Name = "Your Second Folde
Name" or flr.Name = "Your Third Folder Name" The
 
R

rpfields

States that there is a run time error
see attachment :)

Thank you...when i run debug, it highlights the depth + 1 command.

I am running outlook 2000 thoug

+----------------------------------------------------------------
| Attachment filename: runtimeerror.jpg
|Download attachment: http://www.outlookforum.com/forums/attachment.php?postid=217065
+----------------------------------------------------------------
 
S

s0lar1s8

hmmmm. i do not get that error. i cannot re-create that runtime error.
do you use vb 6?
do you have 4 these references checked? (under Tools)
Visual Basic for Applications
Microsoft Office 10.0 Object Library
Microsoft Outlook 10.0 Object Library
OLE Automation
===============
 
J

jefcole

Just before that offending line enter
on error resume next
just after that line enter
on error goto 0.

Normally this is bad form, but in this case the risk is low.

It appears that Outlook 2000 doesn't like a folder depth greater tha
7. When I attempted this macro, I received the error on the depth +
line when the depth was 7. However, the process had completed all m
folders and was trolling through the public folders where it ran acros
a folder depth of 8. Recovering from the error allowed the processin
to continue to completion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top