Skip to main content

[archive] Send email via COBOL program

  • February 21, 2007
  • 5 replies
  • 0 views

[Migrated content. Thread originally posted on 20 February 2007]

Does anyone have any experience sending an email from a OCBOL program. We are using MSMAPI and as long as I am sending from a local machine it is possible. However, when I try the same function while running our system through Remote Desktop (Terminal Services) I get errors.

I can go into more details about the errors if I find someone that has some experience in this.

Thanks in advance for all your help.

5 replies

[Migrated content. Thread originally posted on 20 February 2007]

Does anyone have any experience sending an email from a OCBOL program. We are using MSMAPI and as long as I am sending from a local machine it is possible. However, when I try the same function while running our system through Remote Desktop (Terminal Services) I get errors.

I can go into more details about the errors if I find someone that has some experience in this.

Thanks in advance for all your help.
The error message we now get is 'Bad Recipient Type' occuring on the SEND (MAPISendMail).

Apparently, we resolved the logon issues!

[Migrated content. Thread originally posted on 20 February 2007]

Does anyone have any experience sending an email from a OCBOL program. We are using MSMAPI and as long as I am sending from a local machine it is possible. However, when I try the same function while running our system through Remote Desktop (Terminal Services) I get errors.

I can go into more details about the errors if I find someone that has some experience in this.

Thanks in advance for all your help.
The MSMAPI interface is quite complex and requires among other things use of memory arrays if you for instance want to have multiple recipients.

Bad Recipient type may be due to a number of reasons, obviously, without a single line of example code, it is difficult to state the exact cause.

As I said, the MSMAPI interface is old and difficult to use, why don't you use the MSMAPI OLE object or Outlook object via COM instead? These are much easier to use and there are numerous examples.

Also, you can use smtp and the socket functionality in the runtime to send emails, this is probably the most straight forward approach, and again, there are examples. In fact search the forum for smtp and you should find a full example, courtesy KISS gmbh, Germanhy.

[Migrated content. Thread originally posted on 20 February 2007]

Does anyone have any experience sending an email from a OCBOL program. We are using MSMAPI and as long as I am sending from a local machine it is possible. However, when I try the same function while running our system through Remote Desktop (Terminal Services) I get errors.

I can go into more details about the errors if I find someone that has some experience in this.

Thanks in advance for all your help.
I will take your advice and explore those other possibilities.

We actually made a discovery yesterday. We were able to send the email when connected via remote desktop from one PC to another. However, sending through our server gives us the same error. The major difference we know of right now is the OS on our PC's is XP and the server is 2003.

Thanks again.

[Migrated content. Thread originally posted on 20 February 2007]

Does anyone have any experience sending an email from a OCBOL program. We are using MSMAPI and as long as I am sending from a local machine it is possible. However, when I try the same function while running our system through Remote Desktop (Terminal Services) I get errors.

I can go into more details about the errors if I find someone that has some experience in this.

Thanks in advance for all your help.
This can be something as simple as that you have different privileges when logged on a terminal server than your local.
If you are using smtp.xyz.com from your local machine, xyz being your internet provider it will work like a champ. But when you are on the remote machine, you might be under zyx domain, in that case smtp.xyz.com will refuse your connection because you are not a member of the domain. The silly response you get in this case then is that the recipient is bad.
An alternative to pursue is then to change the smtp account of the email client MSMAPI uses (this will be the default email app of the machine). But as I said, this is just one of many possibilities. So I think it is a wise decision of yours, to pursue an alternate path.

[Migrated content. Thread originally posted on 20 February 2007]

Does anyone have any experience sending an email from a OCBOL program. We are using MSMAPI and as long as I am sending from a local machine it is possible. However, when I try the same function while running our system through Remote Desktop (Terminal Services) I get errors.

I can go into more details about the errors if I find someone that has some experience in this.

Thanks in advance for all your help.
I took your advice and went a different path. I used Outlook object via COM and all is well. I see there is software you can purchase that will supress the warnings when the system is sending an email. That is the next step.

Thanks for your help!