It's been a while but I decided to give this a go once more.
This is a sort of literal translation with some VB stuff left in it cause I don't know (yet) how to convert it to kix. Above these lines there is a line starting with !!!!. In total there are three lines I have no clue of how to convert them.
Like said this is a literal translation and there might be more lines that do not work. I gave it a go and it errored out on the $oSession.Logon , , False, True, , True, $strProfileInfo line.
Any help is much appreciated.
Code:
Dim $oSession, $oInfoStores, $oInfoStore, $StorageUsed, $NumMessages, $strProfileInfo, $sMsg, $server, $mailbox
$server = "mailserver"
$mailbox = @USERID
If $server = ""
?"Please specify a server."
Sleep 5
Exit
Else
If $mailbox = ""
?"Please specify a mailbox."
Sleep 5
Exit
EndIf
EndIf
;Create Session object.
$oSession = CreateObject("MAPI.Session")
If @ERROR
$sMsg = "Error creating MAPI.Session."
$sMsg = $sMsg + "Make sure CDO 1.21 is installed. "
$sMsg = $sMsg + @ERROR + " " + @SERROR
?$sMsg
Exit @ERROR
EndIf
$strProfileInfo = $server + " " + $mailbox
;Log on.
;!!!! This line is untranslated and therefor gives errors !!!!
$oSession.Logon , , False, True, , True, $strProfileInfo
If @ERROR
$sMsg = "Error logging on: "
$sMsg = $sMsg +@ERROR + " " + @SERROR
?$sMsg
?"Server: " $server
?"Mailbox: " $mailbox
$oSession = 0
Exit @ERROR
EndIf
;Grab the information stores.
$oInfoStores = $oSession.InfoStores
If @ERROR
$sMsg = "Error retrieving InfoStores Collection: "
$sMsg = $sMsg + @ERROR + " " + @SERROR
?$sMsg
?"Server: " + $server
?"Mailbox: " + $mailbox
$oInfoStores = 0
$oSession = 0
Exit @ERROR
EndIf
;Loop through information stores to find the user's mailbox.
For Each $oInfoStore in $oInfoStores
If InStr($oInfoStore.Name, "Mailbox - ")
;!!!! This line gives errors !!!!
$StorageUsed = $oInfoStore.Fields(&HE080003)
If @ERROR
$sMsg = "Error retrieving PR_MESSAGE_SIZE: "
$sMsg = $sMsg + @ERROR " " + @SERROR
?$sMsg
?"Server: " + $server
?"Mailbox: " $mailbox
$oInfoStore = 0
$oInfoStores = 0
$oSession = 0
Exit @ERROR
EndIf
;!!!! This line gives errors !!!!
$NumMessages = $oInfoStore.Fields(&H36020003)
If@ERROR
$sMsg = "Error Retrieving PR_CONTENT_COUNT: "
$sMsg = $sMsg +@ERROR + " " + @SERROR
?sMsg
?"Server: " $server
?"Mailbox: " $mailbox
$oInfoStore = 0
$oInfoStores = 0
$oSession = 0
Exit @ERROR
EndIf
$sMsg = "Storage Used in " $oInfoStore.Name
$sMsg = $sMsg + " (bytes): " + $StorageUsed
?$sMsg
?"Number of Messages: " + $NumMessages
EndIf
Next
;Log off.
$rc = $oSession.LogOff
;Clean up memory.
$oInfoStore = 0
$oInfoStores = 0
$oSession = 0