IMail is an excellent mail server program based on win platform, which is widely used in small and medium-sized applications.
IMail has three user data interface methods:
· Default mode: stored in the system registry.
· System account: user data depends on NT/2000 user management
· External data mode: External Database mode connected using ODBC Interfaces
If you want to manage your IMail account programmatically, you can use an external database to manage your mail account. The following describes how to use SQL Server to manage IMail accounts.
Before using external databases, you need to create a system data source DSN (Data Source Name) in the control panel ). This dsn points to an SQL Server database. The database name and DSN name can be any one, such as imaildb. Note that the TCP/IP naming pipeline must be used to ensure proper use.
After configuring the data source, you can use this DSN to create a new email domain for the database.
1. in Imail administrator, right-click localhost and select Add host.
2. Skip the welcome page and enter a domain name
3. select External Database and click configur. The external user database dialog box appears.
IMail uses a dynamic link library DLL to connect to the external database. IMail comes with an exemplary DLL file odbcuser. DLL. This dll uses the ODBC method to access data, but you can also develop your own DLL and use other methods to access the external database. This custom dll must implement getuserentry, setuserentry, deleteuserentry, authorizeuser, getfirstuserentry, getnextuserentry, and other methods. You can download the source code and interfaces of odbcuser. dll from inswitch.com.
In the external user database dialog box, enter the full path of odbcuser. dll (or custom DLL) in the external database impementation DLL, and enter the name of the DSN to be created in the ODBC system data source name. In SQL Server 7.0 or later versions, you must specify the connection username and password dsn_name; uid = <username>; Pwd = <password> for The DSN domain. Enter the name of the email user table to be created in table name. If [Default] is maintained, IMail automatically uses the email domain name as the table name.
Click OK. IMail automatically creates an email account table in the database specified by DSN. This table has the following structure:
Userid-varchar (31) ...... Username
Password-varchar (31) ...... Password
Fullname-varchar (63) ...... full name
Userdir-varchar (255) ...... user directory
Mailaddr-varchar (255) ...... email address (such as abc@my.com)
Maxsize-integer ...... maximum mail size
Maxmsgs-integer ...... maximum Message Size
Flags-integer
Type-integer
Numtries-integer
Attempttime-integer
Numtimessusp-integer
Lastlogin-integer
Spndusracct-integer
Icalenbl-integer
Spellenbl-integer
Numsgstns-integer
Iwdepth-integer
Iwoptions-integer
Spellchkg-integer
Prvwsize-integer
Defview-varchar (40)
Timezone-varchar (255)
Strtday-integer
Defcalnm-varchar (40)
Entrygrnl-integer
Starttime-integer
Endtime-integer
Maxevntdisp-integer
Maxtskdisp-integer
Maxnotedisp-integer
Maxdlyrcurcnt-integer
Maxwklyrcurcnt-integer
Maxmonrcurcnt-integer
Maxyrlyrcurcnt-integer
Dispcmpltdtsks-integer
Hoursclock-integer
Maxsrchresppg-integer
Maxeventtitlelen-integer
Maxtasktitlelen-integer
Confirmondelete-integer
Now, the IMail account is managed by SQL Server. Later, you can use IMail administrator to add user accounts, or directly add user accounts to SQL Server. In this way, the user account can be automatically created through programming. Two steps are required:
1. Create a mail storage directory for the user account on the mail server
2. Add User account records in the SQL server data table. You can directly insert records or use stored procedures.