Automatically make sure that new email addresses are unique
Top  Previous  Next


[Settings_Begin]
BatchSettings.Delimiter=TAB
Account.FullName.Col=1
SET username=%col4%    // %username% instead of %col4% below = easier to change column
Account.Password.col=5
Account.Description.Col=6
BatchSettings.MarkerCol=7
Account.Password.MustChange=No
Account.Expires=Never
SET ExchContPath=o=y/ou=D30/cn=Recipients
SET NTdomain=D30
SET EmailSuffix=acme.com
[Settings_End]

[Machines_Begin]
\\EDU2830      NT PDC    
[Machines_End]

[Init_Batch_Begin]
// Compare with existing e-mail addresses, add number if same   
Data.Column.DupeCheck 4,E55Mail,edu2830/%ExchContPath%,AddNumber   
[Init_Batch_End]

[Batch_Begin]
Data.Loop          
Account.Create %username%          
Exchange.55.Mailbox.Create %servername2%,%ExchContPath%,%NTdomain%,%username%,%col1%,@%EmailSuffix%   
Data.Endloop       
[Batch_End]

[Undo_Batch_Begin]
Data.Loop          
Exchange.55.Mailbox.Delete %servername2%,%ExchContPath%,%username%    
Account.Delete %username%          
Data.Endloop       
[Undo_Batch_End]

[Data_Begin]
Deborah Chiel         dc   jidij+w3ee      
Martin Gardner         mg   d23jioE      
William Karush         wk   dko3aaX      
[Data_End]

·Most of the code in this example is from the Exchange 5.5 example Create and delete 100 Internet-enabled accounts in five minutes.  
·The difference is the Data.Column.DupeCheck command in the [Init_Batch] section that compares column four (the part of the email address before the "@" sign) with all existing SMTP addresses. When a duplicate is found, the number "2" is added or an existing trailing number is increased.  
·Notice that the "%servername2%" variable is undefined in the [Init_Batch] section, the server name must be typed in the command.