    '**************************************
    ' Name: Add New Users to EzMTS Mail Serv
    '     er from ASP Page
    ' Description:Allows new users to signup
    '     for an email account via an ASP webpage.
    '     Made for EzMTS e-mail server and is spec
    '     ific to EzMTS.
    The code edits the user database which is just a text file and adds the new user from the webpage.
    This automates the system somewhat.
    It took some effort to edit it properly maintaining the integrity of the file. I have released it for some feeback, hopefully improvements. I think it is far better to Do things this way than With the use of editing addusers.exe which Then must be run from the webpage using WSH.
    Note: The file must be set-up properly For this To work. Remember to set the proper permission so this works. FILE MUST LOOK LIKE BELOW NOTHING ELSE.
    [User]
    Count=3
    User0=Postmaster
    User1=webmaster
    User2=Username
    ;!
    [Passwords]
    webmaster=planetsourcecode
    Username=Password
    ' By: Tony G
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=8423&lngWId=4    'for details.    '**************************************
    
    <%@ LANGUAGE="VBSCRIPT" %>
    '#######################################
    '     ########################################
    '     ###########
    'Allows new users to signup for an email
    '     account via an ASP webpage. 
    'Made for EzMTS e-mail server and is spe
    '     cific to EzMTS. The code edits the user 
    '     database 
    'which is just a text file and adds the 
    '     new user from the webpage. This automate
    '     s the 
    'system somewhat. It took some effort to
    '     edit it properly maintaining the integri
    '     ty of the 
    'file. I have released it for some feeba
    '     ck, hopefully improvements. I think it i
    '     s far better 
    'to do things this way than with the use
    '     of editing addusers.exe to take two para
    '     meters 
    'username and password which then must b
    '     e run from the webpage using WSH. Note: 
    '     The file 
    'must be set-up properly for this to wor
    '     k. Remember to set the proper permission
    '     so this works. 
    'FILE MUST LOOK LIKE BELOW NOTHING ELSE.
    '     5 lines no '
    
    '[User] 
    'Count=1
    'User0=Postmaster 
    ';! 
    '[Passwords] 
    
    'If this page does not find this structu
    '     re in EzMTS, it will crash and corrupt t
    '     he User.file.
    '#######################################
    '     ########################################
    '     #############
    <%
    'New EzMTS Email Accounts
    '#####################################
    'Create a new folder for user
    '#####################################
    Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
    if Not myFSO.FolderExists("C:\Inetpub\mailroot\" & username) Then
    myFSO.CreateFolder("C:\Inetpub\mailroot\" & username)
    Response.Write "Creating environment: E-MAIL FOLDER <BR>"
    Else
    Response.Write "Error creating environment: E-MAIL FOLDER NAME ALREADY EXISTS"
    End if
    '#######################################
    '     #######
    'Delete the renamed EzmTS file previousl
    '     y used
    '#######################################
    '     #######
    if MyFSO.FileExists("C:\EzMTS\EzMTS.old") Then
    myFSO.DeleteFile("C:\EzMTS\EzMTS.old")
    End if
    '#######################################
    '     #############################
    'Create a new EzMTS.User file called EzM
    '     TS.txt will rename it later
    'after we have finished using the origin
    '     al EzMTS.User
    '#######################################
    '     #############################
    if Not myFSO.FileExists("C:\EzMTS\EzMTS.txt") Then
    myFSO.CreateTextFile("C:\EzMTS\EzMTS.txt")
    End if
    Const ForReading= 1
    Const ForWriting= 2
    Const ForAppending = 8 
    Counter = 0
    NewPath = ("C:\EzMTS\EzMTS.txt") 'Path
    Path = ("C:\EzMTS\EzMTS.User") 'Path
    Set Fs = CreateObject("Scripting.FileSystemObject")
    Set File = Fs.OpenTextFile(Path, ForReading)
    Do While Not File.AtEndOfStream
    '#######################################
    '     ###########
    'Find User Count and add 1 e.g Count=3 n
    '     ow Count=4
    '#######################################
    '     ###########
    Select Case Counter
    Case 1:
    File.Skip(6)
    User = File.read(1)
    BeeTime = User + 1
    Gem = (Gem & "Count=" & BeeTime)
    Case Else
    '#####################################
    'Look for ;! identifier and add User#=us
    '     ername
    '#####################################
    F = File.Readline()
    if F = ";!" Then
    Timmy = ("User" & User & "=" & Username & vbCrLf & ";!") 'add variable here
    Gem = (Gem & Timmy & vbCrLf)
    Else
    Gem = (Gem & F & vbCrLf)
    End if
    End Select
    Counter = Counter + 1
    Loop
    Set NewFs = CreateObject("Scripting.FileSystemObject")
    Set Newfile = NewFs.OpenTextFile(newpath, ForWriting)
    '#######################################
    '     #################################
    'Gem now holds the entire edited file wr
    '     ite from EzMTS.User to EzMTS.txt
    '#######################################
    '     #################################
    Newfile.Write(gem)
    'Response.Write(Gem)
    
    File.Close() 
    NewFile.Close()
    Set NewFs = CreateObject("Scripting.FileSystemObject") 
    Set NewFile = NewFs.OpenTextFile(NewPath, ForAppending)
    '#####################################
    'Append Username=Password to the end of 
    '     the EzMTS.txt file
    '#####################################
    NewFile.WriteLine(Username & "=" & Password) 'add variables here
    NewFile.Close
    %>
    <%
    '#######################################
    '     ###########################
    'Reaname EzMTS.User to EzMTS.old & reana
    '     me EzMTS.txt to EzMTS.User
    'In case any goes wrong you can edit thi
    '     s to store old versions of the 
    'User file to try and recover lost infor
    '     mation should it happen.
    '#######################################
    '     ###########################
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.MoveFile "C:\EzMTS\EzMTS.User" , "C:\EzMTS\EzMTS.Old"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.MoveFile "C:\EzMTS\EzMTS.txt" , "C:\EzMTS\EzMTS.User"
    %>