Page 1 of 1

Add Users and Aliases from CSV

Posted: 2005-09-21 18:34
by JasonMcFeetors
While I was setting up my new mail server, I wrote this script to create the users and aliases. You simply put all of the users and the aliases into a CSV file and run the script. Once it finishes, all of your users and aliases should be created for you.

Code: Select all

Option Explicit

Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewAlias,i

Const ForReading = 1
 
Set obBaseApp = CreateObject("hMailServer.Application") 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("Objects.csv", ForReading) 'Change the name of Objects.csv to the name of your CSV file that you put in the same directory as the script.

Do While objTextFile.AtEndOfStream <> True
    strNewAlias = split(objTextFile.Readline, ",")

    Select Case strNewAlias(0)
    	Case "User"
		    AddUser strNewAlias(1), strNewAlias(2), strNewAlias(3)
    	Case "Alias"
		    AddAlias strNewAlias(1), strNewAlias(2), strNewAlias(3)
    End Select
    
    i = i + 1
Loop

Sub AddAlias(strAlias,strEmailAddress,strDomain)
	Dim obDomain 
	Dim obAliases 
	Dim obNewAlias

	Set obDomain = obBaseApp.Domains.ItemByName(strDomain) 
	Set obAliases = obDomain.Aliases
	Set obNewAlias = obAliases.Add() 
	
	obNewAlias.Name = strAlias & "@" & strDomain 'username
	obNewAlias.Value = strEmailAddress 'password
	obNewAlias.Active = 1 'activates user
	obNewAlias.Save() 'saves account
	
	Set obNewAlias = Nothing
	Set obAliases = Nothing
	Set obDomain = Nothing	
	
End Sub

Sub AddUser(strUsername, strPassword, strDomain)
	Dim obDomain 
	Dim obAccounts 
	Dim obNewAccount

	Set obDomain = obBaseApp.Domains.ItemByName(strDomain) 
	Set obAccounts = obDomain.Accounts
	Set obNewAccount = obAccounts.Add() 
	
	obNewAccount.Address = strUsername & "@" & strDomain 'username
	obNewAccount.Password = strPassword 'password
	obNewAccount.Active = 1 'activates user
	obNewAccount.Maxsize = 0 'sets mailbox size, 0=unlimited
	obNewAccount.Save() 'saves account
	
	Set obNewAccount = Nothing
	Set obDomain = Nothing	
	Set obAccounts = Nothing
	
End Sub
Make sure that the CSV file you create is in the same directory as the sccript otherwise the script will fail. Also, the CSV file needs to be in the following format:

Code: Select all

EntryType,Field1,Field2
The EntryType can be one of two options, User or Alias. If the EntryType is User, then:

Field1 - Username
Field2 - Password
Field3 - DomainName

If the EntryType is Alias, then:

Field1 - AliasName
Field2 - ForwardingEmail
Field3 - DomainName

So, for example, if you had the following CSV file:

Code: Select all

User,tjones,mypassword,jones.com
Alias,tommy,tjones@jones.com,jones.com
This would create a user names tjones@jones.com in the jones.com domain and an alias tommy@jones.com which will forward all e-mail to tjones@jones.com in the jones.com domain.

Hope you find this to be helpful.

Posted: 2005-12-20 15:40
by lusitano
Hello,

How to use this script??

Thank you :oops:

Posted: 2006-01-19 01:44
by hodown
to use the script copy the code and save it as import.vbs. You then need to create the Objects.csv as explained above.

does anyone have a version of this script that adds domains in on the fly also? This script doesn't cater for this.

Posted: 2006-01-27 17:51
by pjcarmen
Great work, thanks! You saved quite a bit of time today. I had to add 60 users as well as an alias for each. Granted it's not that many users, but I tend to "fat finger" :shock: things, so this was a huge help.

It worked perfectly, once I realized that "alias" had to be "Alias", I guess it expects capitalization.

Any way to add to or modify this to help to create distribution lists?

-PJC

Posted: 2006-02-19 01:19
by Jimi_l
What if it needed to be modified to import a CSV into the distribution list?

Apparently there are also three fields in that DB. The first is a numerical id (1,2,3, etc) the second field all have a 5 and the third is the actual E-mail address that would be imported from a CSV text file.

If this could work it would really save my bacon.

Jim

Posted: 2006-04-06 21:29
by hodown
hodown wrote:to use the script copy the code and save it as import.vbs. You then need to create the Objects.csv as explained above.

does anyone have a version of this script that adds domains in on the fly also? This script doesn't cater for this.
This script adds domains to hmailserver. Usage is: scriptname.vbs domainname.com

Therefore if you copied the following code into a file and called it 'scriptname.vbs', executed the script from the command line as above usage it would add a domain called 'domainname.com' to hmailserver:

Code: Select all

Set oArgs = WScript.Arguments 
If oArgs.count <> 1 Then 
   WScript.Quit 
End If 

Dim obBaseApp 
Set obBaseApp = CreateObject("hMailServer.Application") 

Dim obNewDomain 
Set obNewDomain = obBaseApp.Domains.Add() 

obNewDomain.Name = oArgs(0) 
obNewDomain.Active = True 
obNewDomain.Save() 

obBaseApp.Domains.Refresh()

csv for distribution lists

Posted: 2006-07-19 14:39
by mputnam
Jimi_l wrote:What if it needed to be modified to import a CSV into the distribution list?

Apparently there are also three fields in that DB. The first is a numerical id (1,2,3, etc) the second field all have a 5 and the third is the actual E-mail address that would be imported from a CSV text file.

If this could work it would really save my bacon.

Jim

Hello All,
I understand in theory what the script is doing, but being a novice in this sort of thing, am a bit afraid to attempt to modify and possibly "muck up" the dbase. Can someone help me with the changing the script to upload a csv file to the dbase, for a distribution list. I have a hefty list to move over and would rather not manage with manual inserts to the dbase. :wink:
Thanx in advance

Re: csv for distribution lists

Posted: 2006-07-19 23:30
by CraigHarris
Hello All,
I understand in theory what the script is doing, but being a novice in this sort of thing, am a bit afraid to attempt to modify and possibly "muck up" the dbase. Can someone help me with the changing the script to upload a csv file to the dbase, for a distribution list. I have a hefty list to move over and would rather not manage with manual inserts to the dbase. :wink:
Thanx in advance
Try

Code: Select all

<?php
  //Note: This code has not been properly tested and is provided without warranties of any kind - use at your own risk.
  //Assumes perfect settings & file format as there is no proper error checking.

  $Filename = 'W:\Emails.csv';
  $FileType = 'csv'; // 'csv' expects comma's between fields, and new lines between records | ',' means comma seperated addresses with no new lines.
  $EmailField = 0; //0=first field, 1=2nd field ... (only applies if $FileType is csv)
  $DistributionList = 'List@Example.com';

  $DomainName = substr($DistributionList, strpos($DistributionList, '@')+1);

  $hMail = new COM('hMailServer.Application');
  $hMail->Connect();
  $Domain = $hMail->Domains->ItemByName($DomainName);
  $DistLists = $Domain->DistributionLists();
  $DistList = $DistLists->ItemByAddress($DistributionList);
  $Recipients = $DistList->Recipients();

  function AddEmailToList($EmailAddress) {
    global $Recipients;
    $Recipient = $Recipients->Add();
    $Recipient->RecipientAddress = trim($EmailAddress, ' ,');
    $Recipient->Save();
  }

  $LinesRead = 0;
  $EmailCount = 0;

  $fh = fopen($Filename, 'r');
  if(!$fh) {
    die("Cannot open '{$Filename}'");
  }
  if($FileType == ',') {
    $Addresses = explode(',', file_get_contents($Filename));
    while(list(,$Address) = each($Addresses)) {
      $EmailCount++;
      AddEmailToList($Address);
    }
  } elseif($FileType == 'csv') {
    while(($Line = fgetcsv($fh, 1200, ',')) !== false) {
      $LinesRead++;
      if($Email = strpos($Line[$EmailField], '@') !== false) {
        $EmailCount++;
        AddEmailToList($Line[$EmailField]);
      }
    }
    $ListMembers = $Recipients->Count();
  } else {
    die('Upsupported file type');
  }
  echo <<< EOR
<html>
  <head>
    <title>hMail Distribution List: load report</title>
  </head>
  <body>
    <ul>
      <li>Lines: {$LinesRead}</li>
      <li>Email Addresses: {$EmailCount}</li>
      <li>List members: {$ListMembers}</li>
    </ul>
  </body>
</html>
EOR;
?>
This only makes changes to the specified distribution list - nothing else will be affected.

Posted: 2006-08-07 04:02
by DJP
Just by copied the previous vbs and make transformed it to handle creation of distribution list. I made this very quickly so there probably are errors when distribution list already exist, etc... but worked for me since i was in a hurry to add about 200 mails in 5 distributions list and worked well :P

File format is :
Domain,yourdomain.com,distributionlistname
Mail,myuser1@domain.com
Mail,myuser2@domain.com
Mail,myuser3@domain.com
Domain,yourotherdomain.com,distributionlistname2
Mail,myuser1@domain.com
Mail,myuser2@domain.com
Mail,myuser3@domain.com

Code: Select all

Option Explicit

Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewAlias,i
Dim strDomain, strList

Const ForReading = 1
 
Set obBaseApp = CreateObject("hMailServer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("mylist.csv", ForReading) 'Change the name of Objects.csv to the name of your CSV file that you put in the same directory as the script.

Do While objTextFile.AtEndOfStream <> True
    strNewAlias = split(objTextFile.Readline, ",")

    Select Case strNewAlias(0)
       Case "Domain"
          strDomain = strNewAlias(1)
          strList = strNewAlias(2)
          AddListe strList, strDomain
       Case "Mail"
          AddMail strNewAlias(1), strList, strDomain
    End Select
   
    i = i + 1
Loop

Sub AddListe(strList, strDomain)
   Dim obDomain
   Dim obDistributionList
   
   Set obDomain = obBaseApp.Domains.ItemByName(strDomain)
   Set obDistributionList = obDomain.DistributionLists.Add()
   
   obDistributionList.Address = strList & "@" & strDomain 
   obDistributionList.Active = True
   obDistributionList.Save()
   
End Sub

Sub AddMail(strEmailAddress, strList, strDomain)
   Dim obDomain
   Dim obDistributionLists
   Dim obDistributionList
   Dim obNewMail
   Dim obRecipients

   Set obDomain = obBaseApp.Domains.ItemByName(strDomain)
   Set obDistributionLists = obDomain.DistributionLists
   Set obDistributionList = obDistributionLists.ItemByAddress(strList & "@" & strDomain)
   Set obRecipients = obDistributionList.Recipients
   Set obNewMail = obRecipients.Add()
   
   obNewMail.RecipientAddress = strEmailAddress
   obNewMail.Save() 'saves account
   
   Set obNewMail = Nothing
   Set obDomain = Nothing
   Set obDistributionLists = Nothing   
   Set obDistributionList = Nothing
   Set obRecipients = Nothing
   
End Sub

Posted: 2006-08-23 19:28
by mputnam
DJP wrote:Just by copied the previous vbs and make transformed it to handle creation of distribution list. I made this very quickly so there probably are errors when distribution list already exist, etc... but worked for me since i was in a hurry to add about 200 mails in 5 distributions list and worked well :P

File format is :
Domain,yourdomain.com,distributionlistname
Mail,myuser1@domain.com
Mail,myuser2@domain.com
Mail,myuser3@domain.com
Domain,yourotherdomain.com,distributionlistname2
Mail,myuser1@domain.com
Mail,myuser2@domain.com
Mail,myuser3@domain.com

Code: Select all

Option Explicit

Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewAlias,i
Dim strDomain, strList

Const ForReading = 1
 
Set obBaseApp = CreateObject("hMailServer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("mylist.csv", ForReading) 'Change the name of Objects.csv to the name of your CSV file that you put in the same directory as the script.

Do While objTextFile.AtEndOfStream <> True
    strNewAlias = split(objTextFile.Readline, ",")

    Select Case strNewAlias(0)
       Case "Domain"
          strDomain = strNewAlias(1)
          strList = strNewAlias(2)
          AddListe strList, strDomain
       Case "Mail"
          AddMail strNewAlias(1), strList, strDomain
    End Select
   
    i = i + 1
Loop

Sub AddListe(strList, strDomain)
   Dim obDomain
   Dim obDistributionList
   
   Set obDomain = obBaseApp.Domains.ItemByName(strDomain)
   Set obDistributionList = obDomain.DistributionLists.Add()
   
   obDistributionList.Address = strList & "@" & strDomain 
   obDistributionList.Active = True
   obDistributionList.Save()
   
End Sub

Sub AddMail(strEmailAddress, strList, strDomain)
   Dim obDomain
   Dim obDistributionLists
   Dim obDistributionList
   Dim obNewMail
   Dim obRecipients

   Set obDomain = obBaseApp.Domains.ItemByName(strDomain)
   Set obDistributionLists = obDomain.DistributionLists
   Set obDistributionList = obDistributionLists.ItemByAddress(strList & "@" & strDomain)
   Set obRecipients = obDistributionList.Recipients
   Set obNewMail = obRecipients.Add()
   
   obNewMail.RecipientAddress = strEmailAddress
   obNewMail.Save() 'saves account
   
   Set obNewMail = Nothing
   Set obDomain = Nothing
   Set obDistributionLists = Nothing   
   Set obDistributionList = Nothing
   Set obRecipients = Nothing
   
End Sub
This could be moved to HOW TO
Adding Distribution Lists for Dummies
1) Copy and paste the code into notepad. name the file Dlist.vbs. Place this file on your mailserver in the directory /hmailserver/dbscripts

2) create your file format as shown;
REMEMBER: the first word of each line is critical to the script. Domain (first letter uppercase) will create a new distribution list for that domain. Mail (first letter uppercase) will create a new member address in that domain. You can create multiple distribution lists in one file.

3) After creating the distribution list open it in Hmail and configure the options that allow it to function.

Add addresses to Routes - script

Posted: 2006-09-06 15:08
by craig@ccilegal.co.uk
Hi
Anyone got a script to add addresses to the Routes "deliver to these addresses below"
Craig
PS thanks for the import.vbs script

Script broken in new version?

Posted: 2006-12-01 20:10
by SFM
I am using hmailserver 4.3 and this script dosn't seem to work.

I saw in the forum where another script had to be updated to work in 4.3.

Posted: 2006-12-01 20:12
by martin
Correct. After the line:
Set obBaseApp = CreateObject("hMailServer.Application")
You need to add:
Call obBaseApp.Authenticate("Administrator","your-hmailserver-password")

Otherwise the script won't have access to do what it's supposed to do.

Posted: 2006-12-01 20:15
by SFM
Martin,

Thanks for the reply and developing a great mail server.

Posted: 2008-01-05 17:14
by barcajunior
It did save many time for me.Thank you very much.

powerful green laser pointers

Posted: 2008-01-10 15:46
by Red_Scorpion
Hello Everybody,
I want to add 1500 person's email to distribition list.when I run Script I got this error,

script : c:\programfiles\hMailserver\DBScripts\Dlist.vbs
line :35
Char :4
Error :Subscript out of range
code :800A0009
Source :microsoft VBSript runtime error

how can I do? I need help quickly...
Bilgehan

Posted: 2008-01-10 17:36
by Red_Scorpion
HHOOOAAAREEEEEYYYYY....
it is working...
I'm so happy,
so many thanks everyone...
Red_Scorpion

Re: Add Users and Aliases from CSV

Posted: 2008-09-18 06:06
by plobby
Can anyone help me out with getting this working with the current hmailserver?

Basically I need a line in there or something so it can authenticate...

Re: Add Users and Aliases from CSV

Posted: 2008-09-18 10:05
by ^DooM^
This should do what you need. Find the first line, add the second line.

Code: Select all

Set obBaseApp = CreateObject("hMailServer.Application")
Call obBaseApp.Authenticate ("Administrator", "YourHmailPassword")

Re: Add Users and Aliases from CSV

Posted: 2008-09-18 14:18
by plobby
Thank you very much Doom -- I will try this later.

Re: Add Users and Aliases from CSV

Posted: 2008-09-19 02:07
by plobby
I keep getting the same error -- would it make a difference if I am running an external MySQL database?

Script: C:\Program Files\hMailServer\DBScripts\Dlist.vbs

Line: 35

Char: 4

Error: "You do not have access to this property / method. Ensure that hMailServer.Application.Authentication() is called with proper login credentials."

Code: 800403E9

Source: hMailServer COM Library

Re:

Posted: 2008-09-19 02:29
by ^DooM^
martin wrote:Correct. After the line:
Set obBaseApp = CreateObject("hMailServer.Application")
You need to add:
Call obBaseApp.Authenticate("Administrator","your-hmailserver-password")

Otherwise the script won't have access to do what it's supposed to do.
Martin replied above with the correct code and it looks the same as mine. Are you sure the password is correct?

Re: Add Users and Aliases from CSV

Posted: 2008-09-19 03:01
by plobby
I somehow ran over that and saw it right after you posted your reply -- Yeah I am positive it is the right password. Am I connecting to hmailserver or the mysql database for hmail?

Re: Add Users and Aliases from CSV

Posted: 2008-09-19 09:10
by ^DooM^
You are connected to the COM API not the database.

Re: Add Users and Aliases from CSV

Posted: 2008-09-19 14:57
by plobby
^DooM^ wrote:You are connected to the COM API not the database.
Sorry for all the questions, I just dont feel like entering the mailing list 1 by 1...we have about 200 people on it.

One more, is there a way to test out the password besides through a script or change it? I am positive it is the right password but just to try something different.

Re: Add Users and Aliases from CSV

Posted: 2008-09-19 19:09
by ^DooM^
Easy way to test it is to change the hmail admin password temporarily.

Goto the hMailServer.ini file and find AdministratorPassword. Copy and paste the string of random letters and numbers into another text file. Replace that string with this one

cc03e747a6afbbcbf8be7668acfebee5

Restart the hMail service from windows.

Test your script using the following password test123

If it works with this new password then you have misremembered your old password that you were using in the script. Replace the old code, save it and restart the service again to go back to the original password.

Read this to change the admin password to something more secure if you have forgotten your original password.

http://www.hmailserver.com/documentatio ... r_password

Re: Add Users and Aliases from CSV

Posted: 2008-09-20 01:51
by plobby
Thanks for your help yet again, and patience. I guess I wasn't so positive on it being the correct password.

Re: Add Users and Aliases from CSV

Posted: 2008-09-20 02:12
by ^DooM^
Did you sort it out then mate?

Re: Add Users and Aliases from CSV

Posted: 2008-09-20 02:20
by plobby
Yes I did, thanks a lot!

Re: Add Users and Aliases from CSV

Posted: 2009-02-06 04:47
by desiredforsome
Hey i have 5.0 Does this script work wth that, When i run it it gives me.

Error

line:52
Char:4
Error: You do not have access to this property / method. Ensure that hmailServer.Application.Authticate() is called with proper login cridentals.

What do i do. Im trying to basicaly make a free user signup for email onlien, ANd i figured i can just have them fill out a form that converts it to .csv and then every 5 seconds this script runs on that .csv

Thanks

Re: Add Users and Aliases from CSV

Posted: 2009-07-03 15:49
by gaganuiit
Well i have succeeded with the script.
But i would really want to have one little enhancement be done.
When i am trying to add more members to an existing distribution list, i am getting this error

Failed to save object. Another object with the same name already exists in this domain.
This is because the same distribution list already exists.
Suggestions please.
Dlisterror.jpg

Re: Add Users and Aliases from CSV

Posted: 2009-07-24 10:58
by Melibokus73
Hi ...

Does this original "ADD-Users"script also work with 5.x (5.2) :?:

Re: Add Users and Aliases from CSV

Posted: 2009-07-24 11:23
by ^DooM^
Try it ;)

Re: Add Users and Aliases from CSV

Posted: 2009-08-19 19:43
by Melibokus73
^DooM^ wrote:Try it ;)
It seems to run ... 8)


(after adding the Line with the Password) .... :!:

Re: Add Users and Aliases from CSV

Posted: 2013-05-23 11:14
by jujb.cn
JasonMcFeetors wrote:While I was setting up my new mail server, I wrote this script to create the users and aliases. You simply put all of the users and the aliases into a CSV file and run the script. Once it finishes, all of your users and aliases should be created for you.

Code: Select all

Option Explicit

Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewAlias,i

Const ForReading = 1
 
Set obBaseApp = CreateObject("hMailServer.Application") 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("Objects.csv", ForReading) 'Change the name of Objects.csv to the name of your CSV file that you put in the same directory as the script.

Do While objTextFile.AtEndOfStream <> True
    strNewAlias = split(objTextFile.Readline, ",")

    Select Case strNewAlias(0)
    	Case "User"
		    AddUser strNewAlias(1), strNewAlias(2), strNewAlias(3)
    	Case "Alias"
		    AddAlias strNewAlias(1), strNewAlias(2), strNewAlias(3)
    End Select
    
    i = i + 1
Loop

Sub AddAlias(strAlias,strEmailAddress,strDomain)
	Dim obDomain 
	Dim obAliases 
	Dim obNewAlias

	Set obDomain = obBaseApp.Domains.ItemByName(strDomain) 
	Set obAliases = obDomain.Aliases
	Set obNewAlias = obAliases.Add() 
	
	obNewAlias.Name = strAlias & "@" & strDomain 'username
	obNewAlias.Value = strEmailAddress 'password
	obNewAlias.Active = 1 'activates user
	obNewAlias.Save() 'saves account
	
	Set obNewAlias = Nothing
	Set obAliases = Nothing
	Set obDomain = Nothing	
	
End Sub

Sub AddUser(strUsername, strPassword, strDomain)
	Dim obDomain 
	Dim obAccounts 
	Dim obNewAccount

	Set obDomain = obBaseApp.Domains.ItemByName(strDomain) 
	Set obAccounts = obDomain.Accounts
	Set obNewAccount = obAccounts.Add() 
	
	obNewAccount.Address = strUsername & "@" & strDomain 'username
	obNewAccount.Password = strPassword 'password
	obNewAccount.Active = 1 'activates user
	obNewAccount.Maxsize = 0 'sets mailbox size, 0=unlimited
	obNewAccount.Save() 'saves account
	
	Set obNewAccount = Nothing
	Set obDomain = Nothing	
	Set obAccounts = Nothing
	
End Sub
Make sure that the CSV file you create is in the same directory as the sccript otherwise the script will fail. Also, the CSV file needs to be in the following format:

Code: Select all

EntryType,Field1,Field2
The EntryType can be one of two options, User or Alias. If the EntryType is User, then:

Field1 - Username
Field2 - Password
Field3 - DomainName

If the EntryType is Alias, then:

Field1 - AliasName
Field2 - ForwardingEmail
Field3 - DomainName

So, for example, if you had the following CSV file:

Code: Select all

User,tjones,mypassword,jones.com
Alias,tommy,tjones@jones.com,jones.com
This would create a user names tjones@jones.com in the jones.com domain and an alias tommy@jones.com which will forward all e-mail to tjones@jones.com in the jones.com domain.

Hope you find this to be helpful.

Using the code above, I had made a file of import.vbs, after excuting the import.vbs, screen tip is following:

Script: E:\hMailServer\hMailServer\import.vbs
Line: 52
Char: 4
Error: You do not have access to this property / method. Ensure that hMailServer. Applicaton. Authenticate ( ) is called whth proper login credentials.
Code: 800403E9
Source: hMailServer COM library

I have upload the file of import.vbs.
Would you give me a file of import.vbs without any error?
Thanks!

Re: Add Users and Aliases from CSV

Posted: 2013-05-23 11:32
by mattg
This was probably written for an earlier version.

You will need to authenticate.

Add this line after 'set' lines and before the 'do while'

Code: Select all

Call obBaseApp.Authenticate("Administrator", "SecretPassword")    ' change me
Change to your password, and then run.

Post back if that works (or if it doesn't), and I'll update the script as shown in your post.

Re: Add Users and Aliases from CSV

Posted: 2013-05-23 17:10
by jujb.cn
After added the code(Call obBaseApp.Authenticate("Administrator", "SecretPassword") ' change me),and excuting the import.vbs, screen tip is following as:

Script: E:\hMailServer\hMailServer\import.vbs
Line: 62
Char: 4
Error: Failed to save object. Another object with the same name already exists in this domain.
Code: 800403E9
Source: hMailServer COM library

Re: Add Users and Aliases from CSV

Posted: 2013-05-23 17:36
by percepts
you are trying to add an account which already exists in hms.
The script doesn't trap save errors so there is no logging of which account it is. You can either modify script to trap save errors and report which account is already in hms or analyse your input file for duplicates and against what is already in hms.

N.B. if your script failed half way through then half of the accounts in your input file will be now be in hms.

You really need to modify script to check if account or alias already exists before trying to add it. Or modify to trap failed save(and report because fail may not be due to duplicate) and continue processing input file.

Re: Add Users and Aliases from CSV

Posted: 2013-05-23 18:09
by jujb.cn
Dear Mattg and percepts,

Yours is excellent !

After I deleted accounts which already exist in hMailServer in the objects.csv, I made it.

Thanks!

Jujb.cn

Re: Add Users and Aliases from CSV

Posted: 2013-05-24 01:03
by mattg
percepts has created a ver 5 of this script
http://www.hmailserver.com/forum/viewto ... 20&t=24810

Re: Add Users and Aliases from CSV

Posted: 2014-12-09 14:53
by jr3151006
Can someone tell me if this script also creates the DOMAIN before create users???

Re: Add Users and Aliases from CSV

Posted: 2014-12-09 15:13
by percepts
this version does not. The version I pointed you to does.

Use this one viewtopic.php?f=20&t=24810#p151855

It only adds domains if they are not already there.