Jump to content
Smigacznr1

Outlook cleaner OutlookEX

Recommended Posts

Smigacznr1

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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

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
water

Moving _OL_Open enhances performance.
Correct.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

Ok, what about crash problem?

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1
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
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Smigacznr1

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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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

    • caramen
      By caramen
      I watched _OL_ItemSend&_OL_ItemFind&_OL_ItemCreate in OutlookEx UDF but hmmm
       
      Since it use the test environnement i cant get the orders of the mail creation
       
      Can someone make me win some time of reading all exemples script and lead me how to do one ?
      That whould be lovely.
      Gnight
    • water
      By water
      Extensive library to control and manipulate Microsoft Outlook.
      Theads: Development - General Help & Support - Example Scripts - Wiki
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: 2018-09-01)
      None
    • Gowrisankar
      By Gowrisankar
      Dear members, 
      I am working on a project where, emails from outlook are to be read and moved to various folders within the mailbox, based on the content of the emails.
      I used the below code for moving mails. It works fine when I run it against individual mail ids. But when I run it on Shared mailbox, the mails are not moved to respective folders.
      _OL_ItemMove($oOutlook, $sEntryId, Default, $sDestinationFolder) The value of $sEntryId is saved in an excel report initially. The current process reads the $sEntryId from the excel and passes it to "_OL_ItemMove" statement.
      Requesting the guidance of the forum members in this issue.
    • Gowrisankar
      By Gowrisankar
      Dear members of the forum,
      I need to open the attachments from mails without downloading them. Is it possible using OutlookEx UDF ?
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to get the attachments from mails using OutlookEx UDF and then save them in a particular location.
      The UDF considers even the signature images and other images in the mail body as attachments, and saves it in the folder I point. I want only the proper attachment documents to be saved.
      Requesting the guidance of the forum members.
       
       
      Thanks and regards,
      Gowrisankar R.
×