i'm pretty new to hmailserver and have already searched this but didn't really find what i'm looking for.
I use the program to get status messages from network devices via SMNP and forward them to external email addresses.
This works perfectly, but now we get MFP devices where scan-to-mail is used. So I have to create an account on the server for each user which forwards them to an external account.
Creating all users by hand would be a bit time consuming and I wanted to do this with a VBS script I found on the internet.
The script itself also works great when creating the accounts, but here the external email address and the forwarding is active.
I start the script myself with an Autoit script which passes the parameters to the VBS script until the list is processed accordingly, where the users are listed.
start hmail-create-accounts.vbs Username UserPW domain
Is there the possibility to extend this script so that I can use the parameters
for the external e-mail address and that it is active.
Enclosed the VBS Script
======================================
Code: Select all
Dim hmail, domain, account, email, noOfDomains, userName, userPassword, domainName, hMailAdminAccount, hMailAdminPassword
' These are the hMail admin account defaults after a silent install
hMailAdminAccount = "Administrator"
hMailAdminPassword = "Password"
'===============================================================
' No changes below this line
'===============================================================
' Check for account details from command line
If Wscript.Arguments.Count <> 3 Then
WScript.Quit 1
End If
userName = Wscript.Arguments(0)
userPassword = Wscript.Arguments(1)
domainName = Wscript.Arguments(2)
'msgbox userName & " / " & userPassword & " @ " & domainName,0,"Input params"
email = userName & "@" & domainName
' Get connection to hMailServer
Set hmail = CreateObject("hMailServer.Application")
hmail.Authenticate hMailAdminAccount,hMailAdminPassword
' Check whether domain already exists
noOfDomains = hmail.Domains.Count
domainExists = false
if noOfDomains > 0 then
for i = 0 to noOfDomains-1
set domain = hmail.Domains.Item(i)
if domain.Name = domainName then
domainExists = true
exit for
end if
next
end if
' Create domain if it does not yet exist
if domainExists = false then
set domain = hmail.Domains.Add()
domain.Name=domainName
domain.Active=true
domain.save()
end if
' Check whether account already exists
set accountList=domain.Accounts
noOfAccount = accountList.Count
accountExists = false
if noOfAccount > 0 then
for i = 0 to noOfAccounts
set account = accountList.Item(i)
if account.Address = email then
accountExists = true
exit for
end if
next
end if
' Create account if it does not yet exist
if accountExists = false then
set account=accountList.Add()
account.Address=email
account.Password=userPassword
account.Active=true
account.Forward=True
account.Save()
end if
I would be happy about a positive answer or alternatives to the VBS file.
Translated with www.DeepL.com/Translator (free version)