f.nathan.walsh
New Member
- Joined
- Feb 1, 2010
- Messages
- 9
Hello everyone, I am getting a Run-time error '438' : Object doesn't support this property or method in the code below on this line: sentDate = Format(MItem.SentOn, "mm/dd/yyyy"). Any Ideas?
-Nathan
Sub MoveEmail()
Dim olMAPI As Object 'Outlook.Application
Dim moveFolder As Object 'Outlook.MAPIFolder
Dim InItem As Object 'Outlook.MAPIFolder
Dim MItem As Object 'Outlook.MailItem
Dim sentDate As Date
Dim sentDate2 As Date
Dim myDay As Integer
Dim i As Integer
Dim t As Date
t = Now()
Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
Set InItem = olMAPI.Folders("Mailbox - Walsh, Nathan").Folders("inbox")
Set moveFolder = olMAPI.Folders("F2011").Folders("Inbox")
i = 0
Count = InItem.Items.Count
For i = Count To 1 Step -1
Set MItem = InItem.Items.Item(i)
mySub = MItem.Subject
sentDate = Format(MItem.SentOn, "mm/dd/yyyy")
myDay = Date - sentDate
If myDay >= 14 Then
If MItem.UnRead = False Then
MItem.Move moveFolder
End If
End If
Next
Set moveFolder = Nothing
Set dltFolder = Nothing
Set InItem = Nothing
Set MItem = Nothing
MsgBox "the macro finished in " & Format(Now() - t, "hh:mm:ss")
End Sub
-Nathan
Sub MoveEmail()
Dim olMAPI As Object 'Outlook.Application
Dim moveFolder As Object 'Outlook.MAPIFolder
Dim InItem As Object 'Outlook.MAPIFolder
Dim MItem As Object 'Outlook.MailItem
Dim sentDate As Date
Dim sentDate2 As Date
Dim myDay As Integer
Dim i As Integer
Dim t As Date
t = Now()
Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
Set InItem = olMAPI.Folders("Mailbox - Walsh, Nathan").Folders("inbox")
Set moveFolder = olMAPI.Folders("F2011").Folders("Inbox")
i = 0
Count = InItem.Items.Count
For i = Count To 1 Step -1
Set MItem = InItem.Items.Item(i)
mySub = MItem.Subject
sentDate = Format(MItem.SentOn, "mm/dd/yyyy")
myDay = Date - sentDate
If myDay >= 14 Then
If MItem.UnRead = False Then
MItem.Move moveFolder
End If
End If
Next
Set moveFolder = Nothing
Set dltFolder = Nothing
Set InItem = Nothing
Set MItem = Nothing
MsgBox "the macro finished in " & Format(Now() - t, "hh:mm:ss")
End Sub