Howto: C# DCOM-Remote access from your own .NET App

This section contains user-submitted tutorials.
Post Reply
User avatar
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany

Howto: C# DCOM-Remote access from your own .NET App

Post by Dravion » 2017-07-24 01:09

This Tutorial will show you howto remote access hMailServer progammatically in your Windows Network.

Here you can see how it will look like:

1) Admin permissions on Client-DCOM and Remote DCOM Computer
2) You need a LAN Network with atleast Windows Vista (without Servicepacks installed)
3) You need to install a hMailServer Version 5.4.x or higher Version on your Remotecomputer
4) You needs a copy of the "hMailServer.tlb" file from your hMailServers\bin Install Directory.
5) You need Visual Studio 2017 for .NET Desktop Development installed (Express will work to)

Install hMailServer on your Remotecomputer, you can get it here: ... loadid=256

Copy the hMailServer\bin\hMailServer.tlb file to your Programming Computer

Follow this Howto, to enable Remote Access and make sure you can access
your hMailServer remote Computer with hMailAdmin GUI-Program (double check all settings carefully)

If you want to start a fresh C#.NET Project, follow the "add reference and import the
hMailServer.tlb file to get access to all DCOM API's declaration and Interfaces.

Select Browse and select "hMailServer.tlb" on the next screen and click OK
Now you need the WindowsFormsApp1.7z Archive, unzipp or just goto release bin and execute
WindowsFormsApp1.exe. You can directly access you hMailServer remote computer with it,if you configured everything
the right way as described above.

C# Source snippet: This is basically all you need:

Code: Select all

private void button1_Click(object sender, EventArgs e) {
try {
    var tServerType = Type.GetTypeFromProgID("hMailServer.Application", ed_server.Text);
    var remoteServer = (hMailServer.Application) Activator.CreateInstance(tServerType);
    remoteServer.Authenticate(ed_username.Text, ed_password.Text);

    MessageBox.Show(remoteServer.Version, @"Info", MessageBoxButtons.OK);
catch (COMException comExc) {
                MessageBox.Show(@"Errordetails:"+comExc, @"Error",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
VB.NET, C#.NET, C/C++ (native or not) accessing COM/DCOM diffrently then VBScript or Windows Powershell and doesnt
use Typelibrarys at all, so keep this in mind to avoid Problems.
(54.4 KiB) Downloaded 468 times

Post Reply