Post new topic Reply to topic  [ 20 posts ] 
Author Message
 Post subject: COM API - Connecting to hMailServer on another server
PostPosted: 2012-03-14 11:07 
New user
New user

Joined: 2012-03-14 11:03
Posts: 1
I'm working with the API, which seems to be very well done. When my code is run on the hMailServer machine itself, it works fine. My question is, how can I specify the ip address, etc. of the hMailServer to connect to? I want my code to actually run on a machine seperate from the hMailServer, but be able to programatically connect to hMail and add accounts, etc. I didn't see a way in the documentation or in the forums. Am I missing something?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-03-14 11:14 
Site Admin
User avatar

Joined: 2005-07-29 16:18
Posts: 13805
Location: UK
You are connecting to windows DCOM not hMails TCPIP. It is very difficult to get DCOM running over a network and nigh on impossible to do it over the internet without usually using a VPN and even then it's still difficult. Usual advice is it almost always is run on the same machine as hMail.

_________________
If at first you don't succeed, bomb disposal probably isn't for you! ヅ


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 04:27 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Salvete! I know this is an old post, but I am interested in doing this too. I want to write an application in vb.net that I can run from my computer and update hMailServer.

I have the hMailServer com documentation, and can load the com object model into my VS.

However, Doom, you say this involves DCOM. I know that is a windows service. You say this is difficult, but I would like to try. I have read the page in the documentation regarding "Remote Management".

The first thing I need is a way to tell my application where hMailServer is located in order to authenticate. Do I need to add a reference to the Interop.hMailServer.dll that resides in hMailserver's bin folder, or can I just add the dll to my project? Still, I am not sure how to connect to hMailServer...

Can somebody please steer me in the right direction? Whatever I make I am sure to share with the community.


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 04:43 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
try to get the hmailserver admin gui running from the remote machine.
If you can achieve that then the script will probably just work.

Achieving that is the trick though.

(FYI the hMailserver admin GUI uses only the COM API)

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 04:44 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Do I have to install hMailServer locally (as it relates in the documentation's "Administer hMailServer remotely") and then try to COM into that? I would rather not have to install hMailServer locally at all and just COM into the in-use one that lives on the server.

If a local copy could get the connection string, then surely my COM application can, then, right?

How do I connect?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 07:41 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
mattg wrote:
Achieving that is the trick though.

See 'using hmailserver administration' here >> http://www.hmailserver.com/documentatio ... management

Yes you need to install just the administration GUI, not the entire program.
There is no 'connection string' as such.

I've never been able to get it to work. The few times I'd tried, I ended up just changing my thought processes

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 17:59 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Thanks for your help, Matt. Here's how things have gone for me.

First, I tried copying the bin files to my own computer, and then manually registering the dll. If I try to use regsvr32 on interop.hmailserver.dll, I get an error from RegSvr32: "The module "C:\program Files(x86)\hMailServer\Bin\Interop.hMailServer.dll" was loaded but the entry-point DllRegisterServer was not found. Make sure that "C:\program Files(x86)\hMailServer\Bin\Interop.hMailServer.dll" is a valid DLL or OCX file and then try again.

So I installed hMailserver (hMailServer-5.4-B1942.exe) on my workstation, and during the installtaion options, I deslected "server", although it installed that hMailserver.exe anyway. I am using Windows7 64bit with a local domain account. The server that I am connecting to is not actually joined to the domain (I'll do that someday, but there are a few caveats at the moment), but it works nonetheless!

Okay, the connection with hMailAdmin works, and when I open the admin GUI on my computer, it loads the configuration from the server just fine. I had to specify the server by its ip address instead of dns name, and in the Component Services on the server itself under "DCOM Config", I had to set the hMailServer properties "Authentication Level" to "Connect". And on my workstation, I set the "DCOM Config" properties to run the application on the server.

So I can do all the administration now through the hMailserver on my workstation, using the GUI.

Now, for my own com application:
1. When I add the com reference (vb.net) to Interop.hMailServer.dll, should it be the one in my workstation's hMailServer application folder, or can I link to a copy of the dll that I put in my own application's bin folder?
2. When I use the com functions, how will my application know to connect to the server?
3. Why can't my application DCOM to the server without having hMailServer installed locally? If hMailAdmin.exe uses all COM, then why do I need it when my application can use the same COM? Somewhere there must be a connection string!

(This is fun).


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 21:43 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Hmmm... I've never done this before...

When I try to get my application to access the com functions of the dll, I get this error:
Code:
Retrieving the COM class factory for component with CLSID {D6567EF8-0A6C-48E7-9288-A2463123C2F3} failed due to the following error: 80070424 The specified service does not exist as an installed service. (Exception from HRESULT: 0x80070424).
A first chance exception of type 'System.NullReferenceException' occurred in hMailMan.exe


Now, all I have done so far is this:
Code:
imports hMailServer    'the reference is already set in application properties
Private Property hms As hMailServer.Application
...
hms = New hMailServer.Application


But it IS installed, and the admin GUI works. Now what?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-16 22:58 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Okay, I now know that {D6567EF8-0A6C-48E7-9288-A2463123C2F3} is the ID for the "Application" class inside of the Interop.hMailServer.dll. Hmmm... what now? I've spent hours trying to nail this down.

I can also confirm that Interop.hMailServer.dll is, indeed, a .net com object, and that I am compiling to target a x86 architecture.

I have tried adjusting dcom permissions, like this:
http://www.codeproject.com/Questions/25 ... actory-for
and
http://social.msdn.microsoft.com/forums ... abe59f458/

but I'm still stuck.


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 02:56 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
Mate you have far exceeded my knowledge of this.
I'm out of ideas.

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 03:54 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Thanks, Matt. Is ^DooM^ anywhere to be found?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 04:52 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
He is in the UK (3.00 am there currently)
He checks every message every day.
He will check this later I'm sure...

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 05:11 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Thanks again, Matt. I hope he does check, because I am very interested here, and have already invested a lot of time. I want to make a vb.net application to administer mailing lists with sortable columns, validations, search functions, timestamps and logs for address changes, and list-poster management for Andy's Listserver. If I can only get it to connect, the rest of the application will be fun!

Now, I am thinking about this:
Code:
Retrieving the COM class factory for component with CLSID {D6567EF8-0A6C-48E7-9288-A2463123C2F3} failed due to the following error: 80070424 The specified service does not exist as an installed service. (Exception from HRESULT: 0x80070424).
A first chance exception of type 'System.NullReferenceException' occurred in hMailMan.exe
(hMailMan is the name of my program)

It says, "The specified service does not exist as an installed service."
I wonder if that really means that the interop.hMailServer.dll just can't connect to the server? I can't see any way to tell my app through the COM to connect to the server. There don't seem to be any COM functions exported to that effect. Remember, the hMailAdmin.exe GUI works just fine. If it can connect, sure my application can connect too.

Now, I have assumed that if I use the interop.hMailServer.dll that I installed with hMailServer on my workstation, that it picks up the connection itself, since I have told DCOM to run that dll's code on the server. However, I do notice in the registry, that the CLSID of {D6567EF8-0A6C-48E7-9288-A2463123C2F3} (which is the application class for the dll's COM function) has an "AppID" of {5EDEC473-39E0-43F6-A234-1947071721C8}, which I assume, but don't know for sure, is the id of the local hMailServer.exe that is denoted in the "LocalServer32" key.

How do I associate my application with the DLL, then? It doesn't seem enough to reference it. How does the hMailAdmin connect? I see it using a TCP connection - is it using socket calls?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 11:14 
Site Admin
User avatar

Joined: 2005-07-29 16:18
Posts: 13805
Location: UK
Not sure I can add anything that Matt hasn't already covered.

_________________
If at first you don't succeed, bomb disposal probably isn't for you! ヅ


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 15:20 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Doom, well, how does the hMailAdmin connect from my workstation? I notice that if I remove the shared.dll from the application folder, that hMailAdmin doesn't connect. Is there any way for me to interact with that dll?

I see that the hMailAdmin is using a TCP connection - is it using socket calls?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 18:20 
Site Admin
User avatar

Joined: 2005-07-29 16:18
Posts: 13805
Location: UK
It uses DCOM to connect with the service. Microsoft assigned DCOM ports, you need to look those up.

_________________
If at first you don't succeed, bomb disposal probably isn't for you! ヅ


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-17 23:50 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Wow, I was hoping for something easier - like perhaps, that there were some exploitable functions in shared.dll that would handle the DCOM stuff for me, since it is ALL already written and already works!

I found this thread: http://www.codeproject.com/Articles/513 ... x4312557xx which describes how to use DCOM with vb.net, but what next?

Doom, you wouldn't be willing to share some of the DCOM connections source would you? If I make something worthwhile, I promise to give you the code and you could do whatever you want with it.

Failing all that, I suppose another way would be to create a service that runs on the other computer that looks for files dropped in a dropoff directory, then the service could interface hMailServer with COM directly. That bypasses all the DCOM issues completely, and makes the work of the desktop-based GUI independant of any settings other than LAN access to the dropoff directory. But that would require the service to be installed on the host machine.


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-18 00:53 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11881
Location: 'The Outback' Australia
Source for ver 5.4 is here http://hmailserver.com:60951/svn/hms/

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2012-07-18 02:46 
Normal user
User avatar

Joined: 2012-03-29 17:25
Posts: 131
Location: Kansas City
Thanks, Matt! That will give me something to chew on, for sure. Now, how do I get all that in a zip file rather than downloading the documents one by one and putting them back?


Top
 Profile  
 
 Post subject: Re: COM API - Connecting to hMailServer on another server
PostPosted: 2013-08-04 22:56 
New user
New user

Joined: 2013-08-03 10:19
Posts: 5
Hi all,
I know its a pretty much old post now. But please do let me know if anyone is still interested in this. I have setted up a similar environment in which my client applications access the hmail server through dcom. How ever, I accomplished it in Ms Access VBA, not in vb.net.

Do let me know if anybody is still interested, and i will try to document all my steps and will be glad to help.
:)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ] 


Who is online

Users browsing this forum: No registered users and 3 guests



Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group