Cannot move emails to archive - 440 error


New Member
Outlook version
Outlook 365 64 bit
Email Account (as MS Exchange)
Good Morning outlook VBA friends,
Long time listener, First time caller.

I'm really hoping someone here can help me out. I have a company policy where I work that retains email for 365 days and then deletes it. I have created some code through some VBA forums that will / should do the following:
1. scan the specified subfolder that I want to move old messages
2. look for emails that are old than 360 days
3. once it finds an email older that 360 days, move it to another .ost called "archive"
4. display a pop up that tells me how many messages have been moved.

My current version of outlook is:
Microsoft® Outlook® for Microsoft 365 MSO (Version 2202 Build 16.0.14931.21024) 64-bit
Running windows 10

Here is my code below:

 Sub MoveAgedMailSolarwinds()

'Get the function from    Dim objOutlook As Outlook.Application    Dim objNamespace As Outlook.NameSpace    Dim objSourceFolder As Outlook.MAPIFolder    Dim objDestFolder As Outlook.MAPIFolder    Dim objVariant As Variant    Dim lngMovedItems As Long    Dim intCount As Integer    Dim intDateDiff As Integer
    Set objOutlook = Application    Set objNamespace = objOutlook.GetNamespace("MAPI")    Set objSourceFolder = objNamespace.GetDefaultFolder(olFolderInbox).Folders("External")
'Use a folder in a different data file           Set objDestFolder = GetFolderPath("Archive\Inbox")
    For intCount = objSourceFolder.Items.Count To 1 Step -1        Set objVariant = objSourceFolder.Items.Item(intCount)        DoEvents        If objVariant.Class = olMail Then
             intDateDiff = DateDiff("d", objVariant.SentOn, Now)
           ' adjust number of days as needed.            If intDateDiff > 360 Then
              objVariant.Move objDestFolder
              'count the # of items moved               lngMovedItems = lngMovedItems + 1
            End If        End If    Next
    ' Display the number of items that were moved.    MsgBox "Moved " & lngMovedItems & " messages(s)from External."Set objDestFolder = NothingEnd Sub

My error is from this line:

objVariant.Move objDestFolder

The error is a runtime 440 error " cannot move the items"


I really hope someone can help me out. Thank you in advance for taking a look and any help you can provide. Let me know if you need more information.
I appreciate it,

outlook error-vba.PNG

outlook error.PNG
Similar threads
Thread starter Title Forum Replies Date
G Cannot Move Autocomplete File to New Computer Using Outlook 15
B "Your IMAP server wants to alert you to the following: cannot move folder into itself" Using Outlook 3
J Outlook Cannot Move Msgs to Folders (GMAIL IMAP) Using Outlook 1
M Error message: "Cannot move the items..." Using Outlook 2
S New profile, Cannot Move the items Using Outlook 3
D Error message - Cannot move the items.... Using Outlook 1
S Error 0x80040600 + Cannot move the items. The item cannot be moved . . . Using Outlook 9
D User cannot move email messages within Outlook Inbox folder and sub-folders. Using Outlook 0
U Recovered PST file "Cannot move item" error when trying to move e- Using Outlook 6
P Cannot understand how to use Favorites Using Outlook 4
U When opening shared Calendar "The set of folders cannot be opened" Using Outlook 0
J Cannot edit a calendar event received as an invitation Using Outlook 2
L I Cannot Sign Into My Outlook Account? Outlook VBA and Custom Forms 0
CWM550 This rule has a condition that the server cannot process? Using Outlook 1
U Outlook on the iPhone cannot approve filtered Emails Using Outlook 0
Horsepower Cannot delete gmail in iPhone Outlook outbox Using Outlook 1
K Daily Task List Minimized Cannot Display Using Outlook 5
O The linked image cannot be displayed Using Outlook 2
C "The linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file location" Using Outlook 1
B IMAP server rejects sent email - cannot deliver messages Using Outlook 2
T Outlook 2021 Cannot open attachments Outlook DeskTop 2021 Using Outlook 0
S Cannot print Contacts Using Outlook 7
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
T Outlook 2010 Cannot edit Calendar entries in OL 2010. Using Outlook 1
O Cannot expand the folder. The set of folders cannot be opened. You do not have permission to log on. Using Outlook 1
N Item cannot be saved because it was modified by another user or window, and, Item could not be moved... Using Outlook 0
D Cannot populate certain UserProperties in Outlook from Excel Outlook VBA and Custom Forms 2
D Outlook 2016 64bit, Cannot Save in 'HTML', format Using Outlook 1
D cannot view emails in View pane (in the right pane), I only see one line or nothing Using Outlook 21
M Cannot read the calendar Using Outlook 9
T The Linked Image Cannot Be Displayed in Outlook Using Outlook 7
D Outlook 2016 Outlook Error Msg "The operation cannot be performed ..." How to Stop it Using Outlook 4
S Custom Field Cannot Be Displayed In Views Outlook VBA and Custom Forms 2
rubaboo The vew cannot be found Outlook VBA and Custom Forms 0
A Cannot copy this folder because it may contain private items Using Outlook 0
L Cannot open PST file for first session each day Using Outlook 6
David in Mississippi New (Feb 2020) install of Outlook 365 - Cannot specify PST for different accounts Using Outlook 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using accounts in Outlook 2
noshairwan Registry cannot be found, Outlook Security Using Outlook 2
Marc2019 Cannot input Vietnamese Characters on my MSOutlook 2016 in Windows 7 Using Outlook 0
T Cannot remove needless PST Using Outlook 1
Marc2019 Cannot setup Outlook Account on Mac Os 10.6.8 Using Outlook 3
N pst files are recreating automaticaly and cannot be deleted Using Outlook 5
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
T "cannot find the calendar folder for this item" - calendar items stuck in outbox Using Outlook 0
A Created a new user account and the local account cannot see email Using Outlook 3
iwshim outlook 2013 - I cannot see the "Manage Add-ins" Using Outlook 2
T Cannot connect to main BT email account, sub accts okay Using Outlook 0
O The page that you are trying to access cannot be loaded. Using Outlook 0
M Daily Task List Minimized Cannot Display Using Outlook 2

Similar threads