Outlook 2007 - Run-Time error '438'

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
 
One final question. Ever since I started using the above VBA code in Outlook, every time I unlock my computer (Windows XP) the VBA Editor opens to the code. It does not error or anything, it is just annoying. Has this ever happened before and does anyone know of a fix?

-Nathan
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,225,155
Messages
6,183,218
Members
453,152
Latest member
ChrisMd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top