In most aspects, the hMailServer behaves as any other COM API. However, there are a few things which are good to know before starting to write code which utilizes the hMailServer COM API.
Regardless of which hMailServer object you want to access, you need to navigate to it via the hMailServer.Application object. For example, to access a specific domain, you need to create an instance of the hMailServer.Application object, retrieve a collection of all domains using the Domains property and then locate the specific domain. It is not possible to create an instance of the hMailServer.Domains collection to retrieve the specific domain. The reason for this behavior is the COM API authentication mechanisms.
The hMailServer COM API throws exception in the following cases:
To create a new object, you typically run Add() on the parent collection. For example, to add a new domain execute Add() on the Domains collection. The Add() method will return a new object. This new object will only exist in memory, and you need to execute the Save() method on the object to save it in the database. When you execute Save(), the object is saved in the database and added to the collection.