Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Read and then Move to Folder 1

Status
Not open for further replies.

RonRepp

Technical User
Feb 25, 2005
1,031
US
Hi all:

I'm trying to move a bunch of mail items from the inbox to a specific folder. However, if the item is not read, I want to mark it as read before (or after) it is moved.

The move works great, but having problems w/the read.

Code:
Sub Move2Facebook()
Dim NSpace As Outlook.NameSpace
    Dim MailInbox As Outlook.Folder
    Dim DestFolder As Outlook.Folder
    Dim MailItems As Outlook.Items
    Dim MailItm As Object

    Set NSpace = Application.GetNamespace("MAPI")
    Set MailInbox = NSpace.GetDefaultFolder(olFolderInbox)
    Set MailItems = MailInbox.Items
    Set DestFolder = MailInbox.Folders("Facebook")
    
    Set MailItm = MailItems.Find("[from] = 'Facebook'")
    While TypeName(MailItm) <> "Nothing"
        [b][COLOR=blue]'Here, I want MailItm.Read if not read [/color][/b]
        MailItm.Move DestFolder
        Set MailItm = MailItems.FindNext
    Wend
End Sub

Thanks,


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
I'd try this:
Code:
MailItm.UnRead = False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV! Here is the final, in case anyone else wants it:

Code:
Sub Move2Facebook()
    Dim NSpace As Outlook.NameSpace
    Dim MailInbox As Outlook.Folder
    Dim DestFolder As Outlook.Folder
    Dim MailItems As Outlook.Items
    Dim MailItm As Object

    Set NSpace = Application.GetNamespace("MAPI")
    Set MailInbox = NSpace.GetDefaultFolder(olFolderInbox)
    Set MailItems = MailInbox.Items
    Set DestFolder = MailInbox.Folders("Facebook")
    
    Set MailItm = MailItems.Find("[from] = 'Facebook'")
    While TypeName(MailItm) <> "Nothing"
        If MailItm.UnRead = True Then
            MailItm.UnRead = False
        End If
        
        MailItm.Move DestFolder
        Set MailItm = MailItems.FindNext
    Wend
End Sub


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top