Automatisches PST-Import-Script mit AutoIT : Mailstore Emailarchivierung

Vor Benutzung müssen die Zeilen 12-15 beachtet werden. Somit ist die Zeile 14 zu überprüfen und ggf. anzupassen.
Script für AutoITv3:
#include <file.au3>
 
;Einlesen der PST-Files vorname.nachname.pst aus gewünschtem Ordner
$UserList = _FileListToArray( "D:\pst" )
 
For $i = 1 To $UserList[0]
    ; Schleife: alle PSTs in oben angegbenen Ordner
    ; MailStore Client Fenster aktivieren
    If Not WinActivate( "MailStore Client" ) Then WinActivate( "MailStore Client" )
    ; Outlook PST File anklicken
    ;!!!!!!!
    ; ACHTUNG!!!!!!!!!!! Die ID muss mit dem Programm "AutoIt Window Info" ausgelesen werden!
    ;!!!!!!!
    ControlClick( "MailStore Client", "Outlook PST File", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:20]" )
    ;ControlClick( "MailStore Client", "Outlook PST File", "[CLASS:WindowsForms10.BUTTON.app.0.33c0d9d; INSTANCE:20]")
 
    ; PST File auswählen
    WinWait( "MailStore" )
    If Not WinActive( "MailStore" ) Then WinActivate( "MailStore" )
    WinWaitActive( "MailStore")
    ControlClick( "MailStore", "", "[NAME:rdbPST]" )
    Sleep( 2000 )
 
    ; Angabe des Pfades zum PST file
    $pstpfad = "D:\pst\" & $Userlist[$i]
    ControlSend( "MailStore", "", "[NAME:edtPSTFileName]", $pstpfad )
    Sleep( 1000 )
 
    ; NEXT
    ControlClick( "MailStore", "", "[NAME:btnNext]" )
    Sleep( 1000 )
 
    ; Folders
    ControlClick( "MailStore", "", "[NAME:btnChangeFolders]" )
 
    ; Exclude Folders and Subfolders deselektieren
    WinWait( "Select Folders" )
    If Not WinActive( "Select Folders" ) Then WinActivate( "Select Folders" )
    WinWaitActive( "Select Folders" )
    Sleep( 1000 )
    ControlClick( "Select Folders", "", "[NAME:chkAutoExcludeSourceFolders]" )
    Sleep( 1000 )
    ControlClick( "Select Folders", "", "[NAME:btnOK]" )
    Sleep( 500 )
 
    ; Delete Messages in Outlook - nach erfolgreicher Migration werden die Mails aus dem pstfile gelöscht
    WinWait( "MailStore" )
    If Not WinActive( "MailStore" ) Then WinActivate( "MailStore" )
    WinWaitActive( "MailStore")
    ControlClick( "MailStore", "", "[NAME:rdbPST]" )
    Sleep( 1000 )
 
    ; soll dies nicht passieren: diesen Block auskommentieren
    ControlClick( "MailStore", "", "[NAME:btnChangeDeleteCondition]" )
    Sleep( 1000 )
    ControlClick( "Delete in Microsoft Outlook", "", "[NAME:rdbImmediatelyAfterImport]" )
    Sleep( 500 )
    ControlClick( "Delete in Microsoft Outlook", "", "[NAME:btnOK]" )
    Sleep( 500 )
 
    ; NEXT
    WinWait( "MailStore" )
    If Not WinActive( "MailStore" ) Then WinActivate( "MailStore" )
    WinWaitActive( "MailStore")
    ControlClick( "MailStore", "", "[NAME:btnNext]" )
    Sleep( 1000 )
 
    ; wechsel in das Fenster Userauswahl
    For $n = 0 To 4
        ControlSend( "MailStore", "", "", "{TAB}" )
        Sleep( 500 )
    Next
 
    ; entfernen von .pst und somit erstellen der Variable Username
    $Username = StringReplace($Userlist[$i],".pst","")
    ControlSend( "MailStore", "", "", $Username )
    Sleep( 250 )
 
    ; NEXT
    ControlClick( "MailStore", "", "[NAME:btnNext]" )
    Sleep( 250 )
 
    ;Run after klick finish --> ausschalten
 
    ControlClick( "MailStore", "", "[NAME:chkRun]" )
    Sleep( 250 )
 
    ; Finisch
    ControlClick( "MailStore", "You're Almost Done", "[NAME:btnNext]" )
    If Not WinActive( "MailStore" ) Then WinActivate( "MailStore" )
    WinWaitActive( "MailStore")
 
Next