V
vbaNEWBIE
Hello !
I need help in figuring out how to edit the code below (which works) to move
SENT items to a separate personal folder called out here. I want to move
emails that were sent 90 days ago or older to the personal folder. I also
want to move emails that contain attachments that have a size greater than 5
MB. This code will run when called by the user from a Module.
I have not figured out yet how to code an IF statement for Outlook yet much
less one that requires an OR operator as well.
I am using Outlook 2007. Can anyone provide direction for me in this ?
thanks !
Code follows:
Sub MoveItems_Old_and_Large()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderSent)
Set myItems = myInbox.Items
' Set myDestFolder = myInbox.Folders("Personal Mail")
Set myDestFolder =
Outlook.Session.Folders("OldSentItems").Folders("Year2010")
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
End Sub
I need help in figuring out how to edit the code below (which works) to move
SENT items to a separate personal folder called out here. I want to move
emails that were sent 90 days ago or older to the personal folder. I also
want to move emails that contain attachments that have a size greater than 5
MB. This code will run when called by the user from a Module.
I have not figured out yet how to code an IF statement for Outlook yet much
less one that requires an OR operator as well.
I am using Outlook 2007. Can anyone provide direction for me in this ?
thanks !
Code follows:
Sub MoveItems_Old_and_Large()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderSent)
Set myItems = myInbox.Items
' Set myDestFolder = myInbox.Folders("Personal Mail")
Set myDestFolder =
Outlook.Session.Folders("OldSentItems").Folders("Year2010")
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
End Sub