J
James H
I have another question also. I wanted to use a macro to
scan a folder for messages older than four days and move
them to another folder (unfortunately, the rules wizard
doesn't appear to support dynamic dates). In the macro
pasted below, it chokes on .Move(myOldComm) with a type
mismatch error. I don't understand. The receiver of the
message is a MailItem, and myOldComm is a MAPIFolder.
Thanks for your advice.
Sub MoveCaseComms()
Dim App As Object, NS As Object, myInbox As
MAPIFolder, myNewComm As MAPIFolder, myOldComm As
MAPIFolder
' x = MsgBox("This macro is not yet functional.",
vbOKOnly)
' Exit Sub
Set App = CreateObject("Outlook.Application")
Set NS = App.GetNamespace("MAPI")
Set myInbox = NS.GetDefaultFolder(olFolderInbox) '
folderid should be olfolderdeleteditems, ...inbox, etc.
Set myNewComm = myInbox.Folders("New case
communications")
Set myOldComm = myInbox.Folders("Old communications
(open cases)")
For i = 1 To myNewComm.Items.Count
' On Error GoTo EndTask
' Debug.Print i, mynewcomm.Items(i).CreationTime
With myNewComm.Items(i)
If Date - .CreationTime > 4 Then
.Move (myOldComm)
i = i - 1 ' otherwise we'll skip some
End If
End With
GoTo DoNext
EndTask:
Exit Sub
DoNext:
Next i
End Sub
scan a folder for messages older than four days and move
them to another folder (unfortunately, the rules wizard
doesn't appear to support dynamic dates). In the macro
pasted below, it chokes on .Move(myOldComm) with a type
mismatch error. I don't understand. The receiver of the
message is a MailItem, and myOldComm is a MAPIFolder.
Thanks for your advice.
Sub MoveCaseComms()
Dim App As Object, NS As Object, myInbox As
MAPIFolder, myNewComm As MAPIFolder, myOldComm As
MAPIFolder
' x = MsgBox("This macro is not yet functional.",
vbOKOnly)
' Exit Sub
Set App = CreateObject("Outlook.Application")
Set NS = App.GetNamespace("MAPI")
Set myInbox = NS.GetDefaultFolder(olFolderInbox) '
folderid should be olfolderdeleteditems, ...inbox, etc.
Set myNewComm = myInbox.Folders("New case
communications")
Set myOldComm = myInbox.Folders("Old communications
(open cases)")
For i = 1 To myNewComm.Items.Count
' On Error GoTo EndTask
' Debug.Print i, mynewcomm.Items(i).CreationTime
With myNewComm.Items(i)
If Date - .CreationTime > 4 Then
.Move (myOldComm)
i = i - 1 ' otherwise we'll skip some
End If
End With
GoTo DoNext
EndTask:
Exit Sub
DoNext:
Next i
End Sub