Jump to content
Sign in to follow this  
Flak

Need help converting vbs to au3

Recommended Posts

Flak

What I'm trying to accomplish is to automate the process of reattaching pst files in Outlook.  In a perfect world this script would check for currently attached pst files, unload them then search the user's network drive and pc for PST files and then move them all to a central location.  Then reattach them from that location.  But since all of this is new to me, and I apparently took the extremely long route the first time.  I found this and instantly felt ashamed at the way I was taking, lol....  So how would this be converted to au3 and hopefully I can use this as an example going forward.

So what we do is manually detach pst files, run a search for the user pst(s) then move everything to a central location.  We then run this script, tell it where the pst files are located and it re-attaches all of them.

const ForAppending = 8

start_folder = inputBox ("Enter Full Path to PST Files")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutlook = CreateObject("Outlook.Application") 
Set objFolder = objFSO.GetFolder(start_folder)
set objTextFile = objFSO.OpenTextFile ("C:\Temp\PST_ADD_Log.txt", ForAppending, True)

For Each objFile In objFolder.Files
    If LCase(objFSO.GetExtensionName(objFile.Name)) = "pst" Then
        WScript.Echo "Found PST:" & objFile.Name
            On Error Resume Next
        objOutlook.Session.AddStore objFile.Path
            If Err.Number <> 0 Then
                objTextFile.WriteLine(objFile.Name & vbTab & "PST is corrupt or in use")
            else
                objTextFile.WriteLine(objFile.Name & vbTab & "PST opened successfully")
            End If
    End If
Next

Share this post


Link to post
Share on other sites
water

Please have a look at my OutlookEX UDF. It has some functions to work with PST stores.

If you have questions I'm happy to help.


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
spudw2k

this should get you started

$obj = ObjCreate("Scripting.FileSystemObject")

I would agree, but there are also built-in functions in AutoIt worth learning as far as File System accesses. 

Perhaps ObjCreate is useful enough to get started as something that could be used with the "Outlook.Application" COM object.

After some prolonged expose to AutoIt you'll discover the value of using UDFs too as water recommended (and developed.)

I endorse both.

Share this post


Link to post
Share on other sites
water

To work with files in AutoIt as shown in the example VBS code you don't need to use a FileSystemObject.

AutoIt has functions to directly work with files.


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
spudw2k

To work with files in AutoIt as shown in the example VBS code you don't need to use a FileSystemObject.

AutoIt has functions to directly work with files.

ahem :whistle:

that's what I was eluding too.

...there are also built-in functions in AutoIt worth learning as far as File System accesses.

Share this post


Link to post
Share on other sites
water

Sorry for my "double" post - just noticed that is was already mentioned by you.


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
EKY32

did you mean some thing >like this? :ermm:


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

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
Sign in to follow this  

×