Mark Sent Items as Read After Copying with a Rule

Last reviewed on May 8, 2014

Fulvio needs to use rules to move sent messages, but the sent items are not marked read when they are copied to other folders.

I’ve set up a rule for copying any message I send out to a local outbox folder (rather than the one on remote server). Therefore, I’ve uncheck the standard option “save a copy of sent messages”, as I don’t need to duplicate them remotely. Everything works fine: I have no longer remote copies of sent emails, and I have the local ones, but these latter are now bolded as unread. So, I’d like to set my custom rule as: copy sent messages to the local outbox AND mark them as read. Yet it seems to be impossible….

It's not impossible to do, but it won't work with Rules. "After Sending" rules don't support custom actions, run a script, or marking items as read. However, you can use VBA to mark sent items read.

Because the sent item is not in the default data file, you'll need to use the code at Use a folder in another pst or Mailbox to identify the data file. Paste it and the code below into the ThisOutlookSession module in the VB Editor.

Change this line: Set Items = GetFolderPath("New PST\Sent Items").Items to reflect the data file name in the folder list and the folder name you are moving the sent item to.

Code Sample: Mark Moved Messages as Read

To test this code, click in the Application_Startup module and press Run to start it without restarting Outlook. Don't forget to get the GetFolderPath function from Use a folder in another pst or Mailbox.


Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
   Set Items = GetFolderPath("New PST\Sent Items").Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Save
End Sub

Mark deleted items read automatically

To mark messages read as they are moved into a folder within the mailbox, such as the deleted items folder, use the following code sample.

To use the junk mail folder, use
Set Items = Ns.GetDefaultFolder(olFolderJunk).Items

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderDeletedItems).Items
   
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Save
End Sub

Move sent messages using VBA

This code sample moves the sent messages using VBA, rather than a rule.

If the folder you are moving the sent items to is in a different pst file, you'll need the GetFolderPath function at Use a folder in another pst or Mailbox.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Set Items = Session.GetDefaultFolder(olFolderSentMail).Items

End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
    Set MovePst = GetFolderPath("NewPST\Sent Items")
    Item.UnRead = False
    Item.Move MovePst
End Sub

More Information

More VBA samples that mark moved message as read are at:
Marking Sent Items as Read How to mark messages read when they are moved to multiple folders (WindowsITPro)
E-Mail: Mark as read Mark as read when moved to a subfolder of the Inbox (vboffice.net)
Mark mails as Read automatically in Deleted Items Folder after deleting mails from any folder (outlookcode.com)

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

24 responses to “Mark Sent Items as Read After Copying with a Rule”

  1. Claire

    Good to know--though I must say that Gmail's "mark as read" option for foldered mail is a bit quicker than VBA ;)

  2. Fulvio

    Dear Diane,
    said that I'm quite far from being a VBA expert (in fact, this is my very first time), I tried to write down in sequence, under ThisOutlookSession module, what you indicated, following the instructions for replacing the string as well. As soon as I try to run the module to test it, I got an error message (translating from italian): "Invalid attribute within Sub or Function". could you help me further? Thanks
    Hereafter what is currently in my editor:

    Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
    Dim oFolder As Outlook.Folder
    Dim FoldersArray As Variant
    Dim i As Integer

    On Error GoTo GetFolderPath_Error
    If Left(FolderPath, 2) = "\\" Then
    FolderPath = Right(FolderPath, Len(FolderPath) - 2)
    End If
    'Convert folderpath to array
    FoldersArray = Split(FolderPath, "\")
    Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
    If Not oFolder Is Nothing Then
    For i = 1 To UBound(FoldersArray, 1)
    Dim SubFolders As Outlook.Folders
    Set SubFolders = oFolder.Folders
    Set oFolder = SubFolders.Item(FoldersArray(i))
    If oFolder Is Nothing Then
    Set GetFolderPath = Nothing
    End If
    Next
    End If
    'Return the oFolder
    Set GetFolderPath = oFolder
    Exit Function

    GetFolderPath_Error:
    Set GetFolderPath = Nothing
    Exit Function
    End Function

    Private WithEvents Items As Outlook.Items

    Private Sub Application_Startup()
    Set Items = GetFolderPath("Cartelle Personali\Posta Inviata").Items
    End Sub

    Private Sub Items_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Save
    End Sub

  3. Fulvio

    Great! It works perfectly!
    Thanks a million.

  4. Stuart

    Hi Diane

    I got the code in to mark all the emails as read when sent from one email address and stored in a defined folder.
    Now how do I start a new project to do the same thing for the other email address and its defined folder.

    I don't know how to start a new project.

    using outlook 2007

    thanks

  5. Martins

    Hi Diane,

    I try to get this work, but it comes back with: Compile error: "Invalid attribute in Sub or Function" and marks "WithEvents Items As Outlook.Items"

    Thanks for help!

    My full code:

    Private WithEvents Items As Outlook.Items
    Private Sub Application_Startup()
    Set Items = GetFolderPath("New PST\Sent Items").Items
    End Sub
    Private Sub Items_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Save
    End Sub
    Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
    Dim oFolder As Outlook.Folder
    Dim FoldersArray As Variant
    Dim i As Integer

    On Error GoTo GetFolderPath_Error
    If Left(FolderPath, 2) = "\\" Then
    FolderPath = Right(FolderPath, Len(FolderPath) - 2)
    End If
    'Convert folderpath to array
    FoldersArray = Split(FolderPath, "\")
    Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
    If Not oFolder Is Nothing Then
    For i = 1 To UBound(FoldersArray, 1)
    Dim SubFolders As Outlook.Folders
    Set SubFolders = oFolder.Folders
    Set oFolder = SubFolders.Item(FoldersArray(i))
    If oFolder Is Nothing Then
    Set GetFolderPath = Nothing
    End If
    Next
    End If
    'Return the oFolder
    Set GetFolderPath = oFolder
    Exit Function
    GetFolderPath_Error:
    Set GetFolderPath = Nothing
    Exit Function
    End Function

  6. Martins

    P.S. I try to run it for sent mails that are moved to Inbox subfolders..

    Thanks again!

  7. Chris Gilbert

    Don't know if anyone is reading this old thread, but I think if I turn off the save copy in Sent folder in Email Options and handle everything through Rules, then my Journal can't be used to save incoming and outgoing emails as entries there for record-keeping purposes which I find valuable for recreating my work for billing purposes.

  8. Marek

    Hello Diane, I dont know where I am doing mistake but I cannot make this to work. I just copy/paste Martins code from September 25. where I only changed GetFolderPath to right PST folder but i am getting this error: "Compile error: Only valid object module" (Private WithEvents Items... line is in red color). In ThisOutlookSession have I insert Module or Class Module? When I try to insert Class module I am not able to test/save project...
    Please can you provide whole working code - with GetFolderPath? Thank you in advance. Marek

  9. Marek

    No, as I wrote before, I had only insert new "Module/Class Module" Right now I try paste code as you mention but nothing is happening. "Unread" message still remain in Sent folder... No matter if I hit F5 key or Outlook was closed/reopened.

  10. Marek

    Thank you for an answer but I did exactly what you wrote without success. Messages in Sent folder still remain marked as unread. Please can you check my full code:

    Private WithEvents Items As Outlook.Items
    Private Sub Application_Startup()
    Set Items = GetFolderPath("Personal Folders\Sent Items").Items
    End Sub
    Private Sub Items_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Save
    End Sub
    Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
    Dim oFolder As Outlook.Folder
    Dim FoldersArray As Variant
    Dim i As Integer

    On Error GoTo GetFolderPath_Error
    If Left(FolderPath, 2) = "\\" Then
    FolderPath = Right(FolderPath, Len(FolderPath) - 2)
    End If
    'Convert folderpath to array
    FoldersArray = Split(FolderPath, "\")
    Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
    If Not oFolder Is Nothing Then
    For i = 1 To UBound(FoldersArray, 1)
    Dim SubFolders As Outlook.Folders
    Set SubFolders = oFolder.Folders
    Set oFolder = SubFolders.Item(FoldersArray(i))
    If oFolder Is Nothing Then
    Set GetFolderPath = Nothing
    End If
    Next
    End If
    'Return the oFolder
    Set GetFolderPath = oFolder
    Exit Function
    GetFolderPath_Error:
    Set GetFolderPath = Nothing
    Exit Function
    End Function

  11. Marek

    Once again thank you Diane for your patience, but maybe I am stupid enough because after I am hitting RunSub/UserForm(F5) button, nothing is happend. I made two screenshots of my project/outlook. If you have a time, please look at this. http://1drv.ms/1cPCjOE Maybe you will find something what I am still missing...
    Just for testing purpose i have used this guide http://msdn.microsoft.com/en-us/library/office/ff869298.aspx and message box appears correctly.

  12. Marek

    I don't think so Diane. I've already tested it with "Sent Items" and I am getting error: Run-time error 91. http://1drv.ms/1cPCjOE

Leave a Reply

If the Post Coment button disappears, press your Tab key.