How to add new users programmatically...

The most relaiable way of doing that would be using the remoting API, but if you prefer more direct method, here it is (the code in C#):

Make sure to add references to units Argosoft.MailServer.Settings and Argosoft.MailServer.Data located in the root of your mail server installation.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Argosoft.MailServer.Settings;
using Argosoft.MailServer.Data;

namespace AddUserToMailServer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            AddUser();
        }

        private void AddUser()
        {
            XmlServerSettings serverSettings = new XmlServerSettings();
            SqlServerOptions serverOptions = new SqlServerOptions();
            UserRecord userRecord = new UserRecord();
            userRecord.UserName = "john";
            userRecord.DomainGroup = "_Default";
            userRecord.Password = "topsecret";
            Users.InsertUser(serverSettings.ConnectionString, serverSettings.UsersPath,
                userRecord, serverOptions);
        }
    }
}            

If you have further questions, please submit it from our Support Page.

Back to the list of documents

Back to the Mail Server .NET FAQ

Back to the Mail Server .NET