Jump to content
Sign in to follow this  
joshiieeii

Convert VBScript to AutoIT - ActiveX Data Objects Script

Recommended Posts

Guy been working on a script to change the Outlook Web Access (OWA) 2003 signature (had this posted there, but I think the Topic Title was throwing people off). I found this VB script that allows the changing of the ADO ( ActiveX Data Objects ) for OWA.

This is the code I am trying to convert:

rem Update Exchange OWA
Dim oRec
Set oRec=CreateObject("ADODB.Record")
With oRec
  .Open "file://./backofficestorage/iff.uni-stuttgart.de/MBX/"+username,,3
  .Fields("http://schemas.microsoft.com/exchange/previewmarkasread")=2
  .Fields("http://schemas.microsoft.com/exchange/autoaddsignature")=True
  .Fields("http://schemas.microsoft.com/exchange/quicklinks")=1

.Fields("http://schemas.microsoft.com/exchange/signaturetext")=signature_tex
t

.Fields("http://schemas.microsoft.com/exchange/signaturehtml")=signature_htm
l
  .Fields.Update
  .Close
End With
Set oRec = Nothing
End If

This is what I have thus far for autoit:

Dim $domain                 = @LogonDomain  ;pulls domain that user is logged into
Dim $username                   = @UserName ;pulls username that is logged in
Dim $signature_path         = ( @AppDataDir &'\microsoft\signatures')   ;path to Outlook signature default location
Dim $signature_html         = "test.htm" ;name of the global htm signature file 
Dim $signature_text         = "test.txt" ;name of the global txt signature file 

 ; Update Exchange OWA 
Dim $oRec 

$oRec                       =ObjCreate("ADODB.Record")


$oRec.Open("file://./BackOfficeStorage/"& $domain &"/MBX/"& $username &",,3")   ;Opens the user's file

;Dim $test = $oRec.Fields("http://schemas.microsoft.com/exchange/previewmarkasread")
;MsgBox (0,"Test", "Preview Mark As Read = "& $test)
  

  $oRec.Fields("http://schemas.microsoft.com/exchange/previewmarkasread")=2 ;Changes the preview mark as read 0: Mark item displayes in reading pane as read 1: Mark item as read when seletion changes 2: Do not automatically mark items as read
  $oRec.Fields("http://schemas.microsoft.com/exchange/autoaddsignature")=1  ;Changes Options> Automatically include my signature on outgoing messages True/False
  $oRec.Fields("http://schemas.microsoft.com/exchange/signaturetext")= $signature_text ;Sets the text signature to the Global signature
  $oRec.Fields("http://schemas.microsoft.com/exchange/signaturehtml")= $signature_html ;Sets the html signature to the Global signature
  $oRec.Fields.Update ()    ;Updates the fields??

  $oRec.Close ()    ;Closes the user's file
  $oRec = Nothing ;what does this do???

Can anyone help me to convert this? I found the script HERE

*Edit: I wanted to mention that I have been searching everywhere, found the VBscript to Autoit converter, but it is not quite right.

Edited by joshiieeii

Share this post


Link to post
Share on other sites

This should be close:

Dim $domain = @LogonDomain   ;pulls domain that user is logged into
Dim $username = @UserName    ;pulls username that is logged in
Dim $signature_path = (@AppDataDir & '\microsoft\signatures')    ;path to Outlook signature default location
Dim $signature_html = "test.htm" ;name of the global htm signature file
Dim $signature_text = "test.txt" ;name of the global txt signature file

; Update Exchange OWA
$oRec = ObjCreate("ADODB.Record")

With $oRec
    .Open ("file://./BackOfficeStorage/" & $domain & "/MBX/" & $username,"",3) ;Opens the user's file
    .Fields ("http://schemas.microsoft.com/exchange/previewmarkasread") = 2 ;Changes the preview mark as read 0: Mark item displayes in reading pane as read 1: Mark item as read when seletion changes 2: Do not automatically mark items as read
    .Fields ("http://schemas.microsoft.com/exchange/autoaddsignature") = 1  ;Changes Options> Automatically include my signature on outgoing messages True/False
    .Fields ("http://schemas.microsoft.com/exchange/signaturetext") = $signature_text ;Sets the text signature to the Global signature
    .Fields ("http://schemas.microsoft.com/exchange/signaturehtml") = $signature_html ;Sets the html signature to the Global signature
    .Fields.Update ()    ;Updates the fields??
    .Close ()    ;Closes the user's file
EndWith
Edited by big_daddy

Share this post


Link to post
Share on other sites

Hmm.... I am getting a "The requested action with this object has failed" in regards to the line:

.Open ("file://./BackOfficeStorage/"& $domain &"/MBX/" & $username,"",3);Opens the user's file

**Edit: could be the path on my end and nothing wrong with the script, I am looking into it.

Edited by joshiieeii

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  

×
×
  • Create New...