Delete emails older than 6 months

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
livekaspar
Posts: 1
Joined: 17 May 2021, 09:10

Delete emails older than 6 months

18 May 2021, 00:37

Hi,

i need to delete all Items and Subfolders older than 6 months in the Deleted Items Folder, but this script(below) doesn't work correctly.

:think:
-------------------------------------------

Code: Select all

F12::
#SingleInstance
	olApp := ComObjCreate("Outlook.Application")
	olNameSpace := olApp.GetNamespace("MAPI")
	olDestFolder := olNameSpace.Folders("[email protected]").Folders("Deleted Items")
        
EnvAdd, Today, -182, Days
FormatTime, Timestring, %Today%, dd.MM.yyyy HH.mm.ss 

;MsgBox %Timestring%
Loop, % olDestFolder.Items.Count


{
date := olDestFolder.Items(A_Index).CreationTime
if date < Timestring
{
olDestFolder.Items(A_Index).Delete

}
else
{
MsgBox, 64, Done, Scan completed
return
}
}
[Mod edit: [code][/code] tags added.]

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 269 guests