Highlighted
Absent Member.
Absent Member.
2058 views

[archive] Send email via COBOL program

[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.
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Send email via COBOL program

The error message we now get is 'Bad Recipient Type' occuring on the SEND (MAPISendMail).

Apparently, we resolved the logon issues!
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Send email via COBOL program

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Send email via COBOL program

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Send email via COBOL program

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Send email via COBOL program

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!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.