Move all emails in one folder to another when exiting Outlook

  • Thread starter Thread starter linglc
  • Start date Start date
L

linglc

All mails deleted from my Inbox will only be kept for one day in the "deleted
items" folder by my company. Hence, there are times when I lost some mails
because I forgot to move it out from there.
Can someone help me with this task? I want to move all emails in the
"deleted items" folder to another folder in the PST subfolder called "archive
items" whenever I close my Outlook? The PST folder is called "Operations
Finance". Thanks.
 
The problem with that is by the time the Application.Quit event fires all
Outlook objects are out of scope. You would need to manually run the code
before trying to exit Outlook.

Depending on exactly where the "Operations Finance" folder is located the
code would look something like this, assuming that "Operations Finance" is a
subfolder of Deleted Items:

Sub SaveTheTrash()
Dim oSource As Outlook.MAPIFolder
Dim oTarget As OutlookMAPIFolder
Dim oDummy As Object
Dim oToMove As Object
Dim colItems As Outlook.Items
Dim i As Long

Set oSource = Application.Session.GetDefaultFolder(olFolderDeletedItems)
Set oTarget = oSource.Folders.Folder("Operations Finance")

Set colItems = oSource.Items

For i = colItems.Count To 1 Step -1
Set oToMove = colItems(i)
Set oDummy = oToMove.Move(oTarget)
Next
End Sub
 
Thanks! It is working now with minor tweaks.



Ken Slovak - said:
The problem with that is by the time the Application.Quit event fires all
Outlook objects are out of scope. You would need to manually run the code
before trying to exit Outlook.

Depending on exactly where the "Operations Finance" folder is located the
code would look something like this, assuming that "Operations Finance" is a
subfolder of Deleted Items:

Sub SaveTheTrash()
Dim oSource As Outlook.MAPIFolder
Dim oTarget As OutlookMAPIFolder
Dim oDummy As Object
Dim oToMove As Object
Dim colItems As Outlook.Items
Dim i As Long

Set oSource = Application.Session.GetDefaultFolder(olFolderDeletedItems)
Set oTarget = oSource.Folders.Folder("Operations Finance")

Set colItems = oSource.Items

For i = colItems.Count To 1 Step -1
Set oToMove = colItems(i)
Set oDummy = oToMove.Move(oTarget)
Next
End Sub
 
Hi there,

I am looking at doing something similar but I have a personal folder called
"Personal Folders" with a "Deleted Items" Folder under this, what i would
ideally like to do is to move all the items in this Deleted Items folder to
the actual Deleted Items Folder in Outlook today.

You would be able to help me out with a solution to this please?

Thank you

Andrew

Could you please reply to the following email address please

(e-mail address removed)
 
Please do not hijack threads. Start your own.

The view of Deleted Items in Outlook Today is just a view of the Deleted
Items folder. There's no difference between the two.
 
Back
Top