我在http://www.hmailserver.com/documentation/latest/?page=com_example_account_create下面提供了以下代码作为hMailServer的DCOM API提供的代码以下脚本正常工作.它没有任何参考.在安装hMailServer之后,运行以下代码可以创建一个帐户.现在,我在C#中需要相同的东西.他们没有为我提供任何C#我用Google搜索的库,但我没有相关的结果是下面的代码,但根据hMailServer API,他们说你可以将下面的脚本转换成你想要的任何语言.但是怎么样?我甚至不知道如何开始写第一行.有人请帮帮我.
Dim obApp
Set obApp = CreateObject("hMailServer.Application")
' Authenticate. Without doing this, we won't have permission
' to change any server settings or add any objects to the
' installation.
Call obApp.Authenticate("Administrator", "your-main-hmailserver-password")
' Locate the domain we want to add the account to
Dim obDomain
Set obDomain = obApp.Domains.ItemByName("example.com")
Dim obAccount
Set obAccount = obDomain.Accounts.Add
' Set the account properties
obAccount.Address = "account@example.com"
obAccount.Password = "secret"
obAccount.Active = True
obAccount.MaxSize = 100 ' Allow max 100 megabytes
obAccount.Save
Run Code Online (Sandbox Code Playgroud)
将COM对象(hMailServer)添加到C#项目作为参考,并将其余代码转换为C#.
它看起来像这样:
var app = new hMailServer.Application();
// Authenticate. Without doing this, we won't have permission
// to change any server settings or add any objects to the
// installation.
app.Authenticate("Administrator", "your-main-hmailserver-password");
// Locate the domain we want to add the account to
var domain = app.Domains["example.com"];
var account = domain.Accounts.Add();
// Set the account properties
account.Address = "account@example.com";
account.Password = "secret";
account.Active = true;
account.MaxSize = 100; // Allow max 100 megabytes
account.Save();
Run Code Online (Sandbox Code Playgroud)