[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Outlook VBA move olkItem.MessageClass=REPORT.IPM.Note.IPNRN

Posted on 2009-04-08
4
Medium Priority
?
902 Views
Last Modified: 2012-08-14
Got some simple code which was written an example in another question which works great, but when it comes across a read recipt it fails.

When I query the olkItem.MessageClass it gives me REPORT.IPM.Note.IPNRN, so in short everytime I try and move an item of a type 'REPORT.IPM.Note.IPNRN' my code fails.

The code goes through my entire default inbox and moves everything with the completed state, moves to its appropiate folder in Archive.

Any ideas?

Thanks in advance.
Private olkArchiveFolder As Outlook.MAPIFolder
 
Sub ArchiveCompleted()
    Set olkArchiveFolder = OpenOutlookFolder("Archive 2009\Inbox")
    ProcessFolder Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
    MsgBox "All Done"
End Sub
 
Sub ProcessFolder(olkFolder As Outlook.MAPIFolder)
    Dim olkSubfolder As Outlook.MAPIFolder, olkItem As Object, intCount As Integer
    
    Set olkArchiveFolder = OpenOutlookFolder("Archive 2009" & Mid(olkFolder.FolderPath, InStr(3, olkFolder.FolderPath, "\")))
    
    For intCount = olkFolder.Items.Count To 1 Step -1
        Set olkItem = olkFolder.Items.Item(intCount)
        If olkItem.FlagStatus = olFlagComplete Then
            olkItem.Move olkArchiveFolder '<- the 'IPM.Note works fine, but 'REPORT.IPM.Note.IPNRN' fails
        End If
    Next
    
    For Each olkSubfolder In olkFolder.Folders
        ProcessFolder olkSubfolder
    Next
    Set olkSubfolder = Nothing
End Sub
 
Function IsNothing(obj)
  If TypeName(obj) = "Nothing" Then
    IsNothing = True
  Else
    IsNothing = False
  End If
End Function
 
Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder
    Dim arrFolders As Variant, _
        varFolder As Variant, _
        olkFolder As Outlook.MAPIFolder
    On Error GoTo ehOpenOutlookFolder
    If strFolderPath = "" Then
        Set OpenOutlookFolder = Nothing
    Else
        Do While Left(strFolderPath, 1) = "\"
            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
        Loop
        arrFolders = Split(strFolderPath, "\")
        For Each varFolder In arrFolders
            If IsNothing(olkFolder) Then
                Set olkFolder = Session.Folders(varFolder)
            Else
                Set olkFolder = olkFolder.Folders(varFolder)
            End If
        Next
        Set OpenOutlookFolder = olkFolder
    End If
    On Error GoTo 0
    Exit Function
ehOpenOutlookFolder:
    Set OpenOutlookFolder = Nothing
    On Error GoTo 0
End Function

Open in new window

0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 24095213
Hi, tonelm54.

Replace ProcessFolder with the the version below.  It skips over report items.
Sub ProcessFolder(olkFolder As Outlook.MAPIFolder)
    Dim olkSubfolder As Outlook.MAPIFolder, olkItem As Object, intCount As Integer
    
    Set olkArchiveFolder = OpenOutlookFolder("Archive 2009" & Mid(olkFolder.FolderPath, InStr(3, olkFolder.FolderPath, "\")))
    
    For intCount = olkFolder.Items.Count To 1 Step -1
        If olkItem.Class <> olReport Then
            Set olkItem = olkFolder.Items.Item(intCount)
            If olkItem.FlagStatus = olFlagComplete Then
                olkItem.Move olkArchiveFolder '<- the 'IPM.Note works fine, but 'REPORT.IPM.Note.IPNRN' fails
            End If
        End If
    Next
    
    For Each olkSubfolder In olkFolder.Folders
        ProcessFolder olkSubfolder
    Next
    Set olkSubfolder = Nothing
End Sub

Open in new window

0
 

Author Comment

by:tonelm54
ID: 24095237
Ive done something similar to get it working, but would really like to be able to move the 'REPORT.IPM.Note.IPNRN' to my archive folder, if possible
0
 

Author Comment

by:tonelm54
ID: 24095255
..
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24095670
Report items don't have a FlagStatus property, so we can't use the same condition to move them.  Do you have another condition you want to apply, or should the code jsut flatly move them to the archive?
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question