Smigacznr1

Outlook cleaner OutlookEX

18 posts in this topic

#1 ·  Posted

I'm writing Outlook pst cleaner and now I'm stuck. Compiled script is crashing with OS crash message. When I tryied to run script from editor it's exiting itself (mabye it's some type of crash?) always when it's processing on 4-rd pst file. Here is my code:

#include <OutlookEX.au3>
#include <Date.au3>
#include <File.au3>
#include <Array.au3>

_cleanOutlook("Administrator")
_cleanOutlook("Admin")


Exit

Func _cleanOutlook($user)

    $foldery = "Wiadomości-śmieci#?SPAM#?Junk E-mail#?Elementy usunięte#?Deleted Items"
    $tab_folderow = StringSplit($foldery, "#?", 1)

    $tab_pst = _FileListToArrayRec("c:\users\" & $user, "*.pst", 1+4+8, 1, 0, 2)
;~  _ArrayDisplay($tab_pst)

    For $d = 1 To UBound($tab_pst) -1 Step +1

        $outlook = _OL_Open(True)
        _OL_Close($outlook, True)

        $outlook = _OL_Open()

        Local $aStores = _OL_StoreGet($outlook)
    ;~      _ArrayDisplay($aStores)
        For $i = 1 to $aStores[0][0]
            If $aStores[$i][4] = True Then
    ;~          ConsoleWrite(@CRLF & "zamykam pst 2")
                _OL_PSTClose($outlook,$aStores[$i][0])
            EndIf
        Next

;~      _OL_PSTAccess($outlook, "C:\Users\Administrator\Desktop\cos.pst")
        _OL_PSTAccess($outlook, $tab_pst[$d])

        ConsoleWrite(@CRLF & $tab_pst[$d])
;~      $tab_struktury = _OL_FolderTree($outlook, "*", 10)
;~      If @error Then
;~          ContinueLoop
;~      EndIf
;~      _ArrayDisplay($tab_struktury)

        $tab_ktory_pst = _OL_PSTGet($outlook)
;~          _ArrayDisplay($tab_ktory_pst)
        For $a = 0 To UBound($tab_ktory_pst) -1 Step +1

            If $tab_ktory_pst[$a][2] = $tab_pst[$d] Then
;~                  MsgBox(0, "", $tab_ktory_pst[$a][0])
                $nazwa_bazy_pst = $tab_ktory_pst[$a][0]
            EndIf

        Next

;~      MsgBox(0, "", UBound($tab_folderow))
;~      _ArrayDisplay($tab_folderow, $tab_pst[$d])

        ConsoleWrite(@CRLF & "przed while")

        $a = 0

        While $a < 2

            ConsoleWrite(@CRLF & "while 1")

            For $b = 1 To UBound($tab_folderow) -1 Step +1

                ConsoleWrite(@CRLF & "for 1")

                $tab_struktury = _OL_FolderTree($outlook, $nazwa_bazy_pst)
;~              _ArrayDisplay($tab_struktury, $nazwa_bazy_pst)

;~              $folder = _OL_FolderAccess($outlook, StringTrimLeft($tab_struktury[0], 2) & "\" & $tab_folderow[$b])
                $folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $tab_folderow[$b])
;~              ConsoleWrite(@CRLF & "eeee")
                If @error Then
;~                  MsgBox(0, "", "\\" & $nazwa_bazy_pst & "\" & $tab_folderow[$b] & @CRLF & @error)
                    ConsoleWrite(@CRLF & "przechodze do kolejnego " & $b+1)
                    ContinueLoop
                EndIf
;~              _ArrayDisplay($folder, $nazwa_bazy_pst)

                ConsoleWrite(@CRLF & $tab_folderow[$b])

                If $tab_folderow[$b] = "Deleted Items" Or $tab_folderow[$b] = "Elementy usunięte" Then

                    ConsoleWrite(@CRLF & "usuwam kosze")
                    _OL_FolderDelete($outlook, $folder[1], 1)
                    _OL_FolderDelete($outlook, $folder[1], 2)
                    _OL_FolderDelete($outlook, $folder[1], 3)
                    _OL_FolderDelete($outlook, $folder[1], 4)
;~                  _OL_FolderDelete($outlook, $folder[1], 5)

                EndIf

                If $a = 0 Then

                    $tab_maile = ""

                    $data_dzis = @YEAR & "/" & @MON & "/" & @MDAY & " 00:00"
        ;~          $data_dzis = "2017/01/31 00:00"
                    $data_szukana = _DateAdd("D", "-3", $data_dzis)

                    $tab_maile = _OL_ItemFind($outlook, $folder[1], $olMail, "[Received]<'" & StringReplace($data_szukana, "/", "-") & "'", "", "", "EntryID", "", 1)
                    If @error Then
                        ContinueLoop
                    EndIf
        ;~          If UBound($tab_maile) > 1 Then
        ;~              _ArrayDisplay($tab_maile)
        ;~          EndIf

                    If UBound($tab_maile) > 1 Then

                        For $c = 1 To UBound($tab_maile) -1 Step +1

;~                          ConsoleWrite(@CRLF & "usuwam stare maile")
                            _OL_ItemDelete($outlook, $tab_maile[$c][0], "", False)

                        Next

                    EndIf

                EndIf

            Next


            $a = $a + 1

        WEnd


;~      ConsoleWrite(@CRLF & "pokazuje")
;~      $folder[1].Display
        $olFolderInbox.Display

;~      _OL_PSTClose($outlook, $olFolderInbox)
;~      If @error Then
;~          MsgBox(0, "", @error)
;~      EndIf

        Local $aStores = _OL_StoreGet($outlook)
;~      _ArrayDisplay($aStores)
        For $i = 1 to $aStores[0][0]
            If $aStores[$i][4] = True Then
;~              ConsoleWrite(@CRLF & "zamykam pst 1")
                _OL_PSTClose($outlook,$aStores[$i][0])
            EndIf
        Next

        ;_OL_PSTClose($outlook, $folder[1])

        _OL_Close($outlook, True)
        If @error Then
            MsgBox(0, "", @error)
        EndIf

        ConsoleWrite(@CRLF & "zamykam")

        ProcessWaitClose("outlook.exe", 30)

        ProcessClose("outlook.exe")

    Next

EndFunc

 

Outlook and OS is updated. I'm usinn OutlooEX in ver. 1.3.1.0

Any ideas? :)

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Just a few questions:

  • Why do you Open, Close and then Reopen Outlook in the loop?
  • Why do you call _OL_FolderDelete multiple times? Simply use $iFlags = 0 to delete the folder, all items and all subfolders.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

I'm reopening outlook inside loop because it was my last idea to check yesterday. I thought that mabye outlook have some limitation, but  nothing changed.

I don't want to delete whole folder but everything what is inside.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Only call _OL_Open once and move it outside the main loop and close Outlook before you exit the function.
To only delete the items set $iFlag = 2 (does not delete any folders or subfolders - just items)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

Moving out _OL_Open it's not solution for my problem. It doesn't matter if it will be inside or outside loop.

To delete items in folder, all subfolders but leave folder itself I need to use flag 5, right (4+1)?

Share this post


Link to post
Share on other sites

#6 ·  Posted

Moving _OL_Open enhances performance.
Correct.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

Ok, what about crash problem?

Share this post


Link to post
Share on other sites

#8 ·  Posted

Please post the messages you get when running the script from SciTE.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

Sure. Here you are:

Quote

>"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Administrator\Desktop\outlook.au3" /UserParams    
+>12:18:45 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X86 OS:X86  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:C:\Users\Administrator\Desktop\outlook.au3
+>12:18:46 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Administrator\Desktop\outlook.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop

c:\users\Administrator\Documents\Pliki programu Outlook\Outlook.pst
przed while
while 1
for 1
Wiadomoœci-œmieci
for 1
przechodze do kolejnego 3
for 1
przechodze do kolejnego 4
for 1
Elementy usuniête
usuwam kosze
for 1
przechodze do kolejnego 6
while 1
for 1
Wiadomoœci-œmieci
for 1
przechodze do kolejnego 3
for 1
przechodze do kolejnego 4
for 1
Elementy usuniête
usuwam kosze
for 1
przechodze do kolejnego 6
c:\users\Administrator\Documents\Pliki programu Outlook\test@cos.cl.pst
przed while
while 1
for 1
przechodze do kolejnego 2
for 1
przechodze do kolejnego 3
for 1
Junk E-mail
for 1
Elementy usuniête
usuwam kosze
for 1
przechodze do kolejnego 6
while 1
for 1
przechodze do kolejnego 2
for 1
przechodze do kolejnego 3
for 1
Junk E-mail
for 1
Elementy usuniête
usuwam kosze
for 1
przechodze do kolejnego 6
c:\users\Administrator\Documents\Pliki programu Outlook\test@firmaadams.ex.pst
przed while
while 1
for 1
Wiadomoœci-œmieci
for 1
przechodze do kolejnego 3
for 1
przechodze do kolejnego 4
for 1
przechodze do kolejnego 5
for 1
przechodze do kolejnego 6
while 1
for 1
przechodze do kolejnego 2
for 1
przechodze do kolejnego 3
for 1
przechodze do kolejnego 4
for 1
przechodze do kolejnego 5
for 1
przechodze do kolejnego 6
c:\users\Administrator\Documents\Outlook Files\Outlook.pst
przed while
while 1
for 1!>12:18:55 AutoIt3.exe ended.rc:-1073741819
+>12:18:55 AutoIt3Wrapper Finished.
>Exit code: 3221225477    Time: 11.3

 

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

When you search the forum for "1073741819" (mind the removed -) then you will get a lot of hits. Seems to be a problem with how your script is coded.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

It's crashing on

$folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $tab_folderow[$b])

So it's OutlooEX.au3 function problem?

Share this post


Link to post
Share on other sites

#12 ·  Posted

Most of the time it is a problem with the parameters you provide. Can you make sure that all three variables contain valid data?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

When I added

If $tab_ktory_pst = "" Then
                    ConsoleWrite(@CRLF & $nazwa_bazy_pst & "\" & $tab_folderow[$b])
                EndIf

before

$folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $tab_folderow[$b])

it's running fine. How to explain it?

 

Update:

After few compilations it's not running properly again. Strange is that I did not any changes in code...

Variables what I passed to  _OL_FolderAccess are: dh14@firmaadams.pl\SPAM

Variables are correct.

 

Update 15:20:

Ok, I get it! This part of code causes crash :

_OL_FolderDelete($outlook, $folder[1], 1)
                    _OL_FolderDelete($outlook, $folder[1], 2)
                    _OL_FolderDelete($outlook, $folder[1], 3)
                    _OL_FolderDelete($outlook, $folder[1], 4)
                    _OL_FolderDelete($outlook, $folder[1], 5)

Calling _OL_FolderDelete multiple times in this same loop, on this same folder causing crash.

Problem solved :)

Edited by Smigacznr1
update

Share this post


Link to post
Share on other sites

#14 ·  Posted

Can you please explain in words what you try to achieve with your script?
As far as I understand you want to

  • Process all PST files in a folder
  • empty the "deleted items" folder (or how it is named in your language)
  • for all other folders you want to delete all items older x days.

Question:

  • Why do you do this two times (While $a < 2)?
  • Why do you close all PST stores in a loop? Couldn't you just close all of them when starting the script and then process each PST file in a loop?

Suggestions:

  • Access the default folders ("deleted items", "Junk" ...) not by name but by foldertype. So your script becomes language independant.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted

On 24.03.2017 at 3:33 PM, water said:

Can you please explain in words what you try to achieve with your script?
As far as I understand you want to

  • Process all PST files in a folder
  • empty the "deleted items" folder (or how it is named in your language)

That's right.

On 24.03.2017 at 3:33 PM, water said:

Question:

  • Why do you do this two times (While $a < 2)?

I thought that elements deleted from any folder are moved to trash folder, not deleted permanently. But now i removed it and added purge default trash folder at the end of loop.

On 24.03.2017 at 3:33 PM, water said:
  • Why do you close all PST stores in a loop? Couldn't you just close all of them when starting the script and then process each PST file in a loop?

I don't want to leave outlook on Administrator profile with all user files connected to it ;)

Idea is to clean outlook files in whole organization because users don't care about their profiles...

On 24.03.2017 at 3:33 PM, water said:

Suggestions:

  • Access the default folders ("deleted items", "Junk" ...) not by name but by foldertype. So your script becomes language independant.

Good idea, I added it to the end of loop. But we have in our organization outlook files with folders in another languages ex. folder trash in english and polish, so I need to select excatly folder anyway....

Your suggestions are helpful, thanks.

 

Script is crashing again now. For now i have no idea what is wrong. Mabye could you take a look again?

 

Share this post


Link to post
Share on other sites

#16 ·  Posted

Will check as soon as I find some spare time - might take a few days.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Here you are updated script:

#include <OutlookEX.au3>
#include <Date.au3>
#include <File.au3>
#include <Array.au3>

_cleanOutlook("Administrator")

_cleanOutlook("Admin")

Exit

Func _cleanOutlook($user)

    $foldery = "Wiadomości-śmieci#?SPAM#?Junk E-mail#?Elementy usunięte#?Deleted Items"
    $tab_folderow = StringSplit($foldery, "#?", 1)
    
    $tab_pst = _FileListToArrayRec("c:\users\" & $user, "*.pst", 1 + 4 + 8, 1, 0, 2)

    $outlook = _OL_Open()
    
    Local $aStores = _OL_StoreGet($outlook)
    For $i = 1 To $aStores[0][0]
        _OL_PSTClose($outlook, $aStores[$i][0])
    Next
    
    For $d = 1 To UBound($tab_pst) - 1 Step +1

        _OL_PSTAccess($outlook, $tab_pst[$d])
        If @error Then
            ContinueLoop
        EndIf
        ConsoleWrite(@CRLF & $tab_pst[$d])
        $tab_ktory_pst = _OL_PSTGet($outlook)
        If @error Then
            ContinueLoop
        EndIf

        For $a = 0 To UBound($tab_ktory_pst) - 1 Step +1
            If $tab_ktory_pst[$a][2] = $tab_pst[$d] Then
                $nazwa_bazy_pst = $tab_ktory_pst[$a][0]
            EndIf
        Next

        ConsoleWrite(@CRLF & "przed for 1")
        
        For $b = 1 To UBound($tab_folderow) - 1 Step +1
        
            ConsoleWrite(@CRLF & "for 1")

            If $tab_pst[$d] = "c:\users\Administrator\Desktop\japierdo.pst" Then
                ConsoleWrite(@CRLF & $nazwa_bazy_pst & "\" & $tab_folderow[$b])
                MsgBox(0, "", $nazwa_bazy_pst & "\" & $tab_folderow[$b])
            EndIf
            
            $folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $tab_folderow[$b])
            If @error Then
                ConsoleWrite(@CRLF & "przechodze do kolejnego " & $b + 1)
                ContinueLoop
            EndIf

            ConsoleWrite(@CRLF & $tab_folderow[$b])
            
            If $tab_folderow[$b] = "Deleted Items" Or $tab_folderow[$b] = "Elementy usunięte" Then
                ConsoleWrite(@CRLF & "usuwam kosze")
                _OL_FolderDelete($outlook, $folder[1], 5)
                ContinueLoop
            EndIf
            
            $tab_maile = ""
            $data_dzis = @YEAR & "/" & @MON & "/" & @MDAY & " 00:00"
            $data_szukana = _DateAdd("D", "-3", $data_dzis)
            $tab_maile = _OL_ItemFind($outlook, $folder[1], $olMail, "[Received]<'" & StringReplace($data_szukana, "/", "-") & "'", "", "", "EntryID", "", 1)
            If @error Then
                ContinueLoop
            EndIf

            If UBound($tab_maile) > 1 Then
                For $c = 1 To UBound($tab_maile) - 1 Step +1
                    _OL_ItemDelete($outlook, $tab_maile[$c][0], "", False)
                Next
            EndIf
            
            $folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $olFolderJunk)
            If Not @error Then
                $tab_maile = ""
                $tab_maile = _OL_ItemFind($outlook, $folder[1], $olMail, "[Received]<'" & StringReplace($data_szukana, "/", "-") & "'", "", "", "EntryID", "", 1)
                If @error Then
                    ContinueLoop
                EndIf

                If UBound($tab_maile) > 1 Then
                    For $c = 1 To UBound($tab_maile) - 1 Step +1
                        _OL_ItemDelete($outlook, $tab_maile[$c][0], "", False)
                    Next
                EndIf
            EndIf
        Next
        
        $folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $olFolderDeletedItems)
        If Not @error Then
            ConsoleWrite(@CRLF & "Usuwam kosz koniec")
            _OL_FolderDelete($outlook, $folder[1], 5)
        EndIf
        
        $olFolderInbox.Display
        Local $aStores = _OL_StoreGet($outlook)
        For $i = 1 To $aStores[0][0]
            _OL_PSTClose($outlook, $aStores[$i][0])
        Next
        
    Next
    
    _OL_Close($outlook, True)
    If @error Then
        MsgBox(0, "", @error)
    EndIf
    
    ConsoleWrite(@CRLF & "zamykam")
    
    ProcessWaitClose("outlook.exe", 30)
    
    ProcessClose("outlook.exe")

    Return
    
EndFunc

 

Edited by Smigacznr1

Share this post


Link to post
Share on other sites

#18 ·  Posted

First code example: Clear specified folders of an PST by removing all items and all subfolders.

#include-once
#include "..\OutlookEX.au3"
#include <Date.au3>
#include <File.au3>
#include <Array.au3>

Global $oOL = _OL_Open()
$oPSTRoot = _OL_PSTAccess($oOL, "C:\temp\Outlook-UDF-Test.pst")
_ClearFolder($oPSTRoot, $olFolderDeletedItems)
If @error Then Exit MsgBox($MB_ICONERROR, "Error", "Could not clean folder 'Deleted items'. @error = " & @error & ", @extended = " & @extended)
_ClearFolder($oPSTRoot, $olFolderDrafts)
If @error Then Exit MsgBox($MB_ICONERROR, "Error", "Could not clean folder 'Drafts'. @error = " & @error & ", @extended = " & @extended)
_ClearFolder($oPSTRoot, $olFolderJunk)
If @error Then Exit MsgBox($MB_ICONERROR, "Error", "Could not clean folder 'Junk'. @error = " & @error & ", @extended = " & @extended)

Func _ClearFolder($oRootFolder, $iFolderType)
    Local $oStore = $oRootFolder.Store()
    Local $oFolder = $oStore.GetDefaultFolder($iFolderType)
    _OL_FolderDelete($oOL, $oFolder, 5)
    If @error Then Return SetError(@error, @extended)
EndFunc

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • cag8f
      By cag8f
      Hi all.  Does AutoIt have any functions/tools (either built-in or user defined) that can help me automate the process of exporting an OST mailbox to a PST file in Microsoft Outlook (2013)?
      I know how to carry out the process manually.  At the Microsoft Forums, I have asked if it is possible to do the same via a script, but some have said it is not possible.  It may be possible if I was using Microsoft Exchange, but I am not.
      I've seen some posts about an Outlook UDF on this site (here and here), but I don't see any mention of exporting a mailbox.  
      In my post at the Microsoft Forums, many paid third party applications were suggested.  But for now I would like to pursue the custom scripting route as far as I can.
      The ultimate goal of this exercise is to automatically create a weekly backup of my Outlook mailbox for offline storage.
      Thanks in advance.
       
    • zetaimmersion
      By zetaimmersion
      Hi all. 
      I am trying to do 2 things but i cannot seem to get any traction on how to read/implement this idea.
      Premise: PowerPoint file in C\temp\presentation.pptx that contains on the first slide 2 entries as "<one>" and "<two>" which need to be replaced with "user1" and "user2", then a silent Outlook send mail containing the file with a predefined body and subject.
      I narrowed it down to COM objects as the Office does not like intrusive open AutoIt functions. I installed OLE/COM Object Viewer to understand how to create the commands but i am still stuck. So far i am trying to user water's code but i suck
      COM object i was originally trying to modify
      Dim $oPPT, $oPres $oPPT = ObjCreate("PowerPoint.Application") $oPPT.Visible = True $oPres = $oPPT.Presentations.Read Water's code below (0.1% modified)
      #include <File.au3> #include "PowerPoint.au3" #include <misc.au3> Global $sFile = "C:\temp\presentation.pptx" Global $sString2Search = "<username>", $sString2Replace = "Password", $iReplaceOnce = 1, $sFullLogFile = "C:\temp\pptxlog.txt" _ProcessPpt($sFile) Func _ProcessPpt($sFile) $oApp = _PPT_PowerPointApp() Local $bChange = False Local $oInterface = $oApp.Presentations Local $oPresentation = $oInterface.Open($sFile, False, False, False) If @error Then _FileWriteLog($sFullLogFile, "E Error " & @error & " opening File " & $sFile) Return SetError(1, 0, 0) EndIf ;it does not even open my file and from here not sure how to read the text and replace it EndFunc ;==>_ProcessPpt  
    • Gowrisankar
      By Gowrisankar
      Dear members of the forum,
      I'm new to AutoIt and I'm having a good time exploring and enjoying the features of AutoIt.
      For one of my tasks, I've to open few particular mails from outlook based on subject of the mails and then print the mails. Can someone please guide me how to do it?
      My question could be very silly for experts. But I'm just a beginner. Kindly advice.
      Thanks and regards,
      Gowrisankar R.
    • water
      By water
      Anyony interested in a function to retrieve the Outlook mailbox quotas for Exchange mailboxes?
      If yes, then this function could be added to the OutlookEX UDF.
      Result could look like (will later be returned in an array):
       
    • ur
      By ur
      I wrote a macro for outlook to send an email.
      Till yesterday it worked, don't know why it is not working today
      I am getting below error when I ran the macro.