Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Marlene Absent Member.
Absent Member.
4939 views

Sending Email using Gmail and other newer protocols

Jump to solution

We want to send emails from an Acucobol version 6.2 program using various email protocols

We have successfully been able to send emails using the ActiveX control autogen for Outlook.  We have also used the sample program WINBMAIL which uses C$SOCKET to send emails from Yahoo and  MIcrosoft email applications (Live, Outlook, Hotmail, MSN).  However we have not been able to successfully send emails using this version of WINBMAIL with Gmail even after installing STUNNEL.

Our clients use many different email protocols for sending emails and Outlook is not a built-in feature in Windows7.  We do not want to force our customers to install it or have Outlook as their default email client.

Is there a newer version of WINBMAIL that supports the newer email protocols?  Is there a sample program using an ActiveX autogen for Thunderbird?

Old posts on this forum indicate that there is a product from Marshallsoft that can be purchased to send emails.  We don't want to go this route unless there is no other alternative.

Thanks.

0 Likes
1 Solution

Accepted Solutions
Knowledge Partner
Knowledge Partner

RE: Sending Email using Gmail and other newer protocols

Jump to solution

I think that a better way, or at least a different way, is to use VBScript, and invoke it via a CALL "SYSTEM".

A key benefit is:  FREE.

A Google search reveals several such scripts, which are quite similar:

http://cybernetnews.com/vbscript-send-emails-using-gmail/
http://notes.ponderworthy.com/send-email-via-gmail-smtp-by-vbscript

I have recently done one of these scripts for use with my RM/COBOL application.  I used XML Extensions (also available on newer AcuCOBOL releases) to create a parameter file so that the command line was simpler.  (We wanted to do multiple optional attachments, large TO and BCC lists, etc.)  Getting parameters from the XML document in the VBScript is simpler than trying to process a large variety of command line parameters.  Should you need this level of complexity and want to use the command line, I will suggest using named parameters. 

Tom Morrison
Hill Country Software


Tom Morrison
Consultant

View solution in original post

0 Likes
11 Replies
Knowledge Partner
Knowledge Partner

RE: Sending Email using Gmail and other newer protocols

Jump to solution

I think that a better way, or at least a different way, is to use VBScript, and invoke it via a CALL "SYSTEM".

A key benefit is:  FREE.

A Google search reveals several such scripts, which are quite similar:

http://cybernetnews.com/vbscript-send-emails-using-gmail/
http://notes.ponderworthy.com/send-email-via-gmail-smtp-by-vbscript

I have recently done one of these scripts for use with my RM/COBOL application.  I used XML Extensions (also available on newer AcuCOBOL releases) to create a parameter file so that the command line was simpler.  (We wanted to do multiple optional attachments, large TO and BCC lists, etc.)  Getting parameters from the XML document in the VBScript is simpler than trying to process a large variety of command line parameters.  Should you need this level of complexity and want to use the command line, I will suggest using named parameters. 

Tom Morrison
Hill Country Software


Tom Morrison
Consultant

View solution in original post

0 Likes
Marlene Absent Member.
Absent Member.

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Thank you so much Tom for your reply.  I implemented your suggestion about calling a VBScript and I was able to successfully send emails from GMail and other email protocols.  I've never used VBScript before so there was a learning curve.

I haven't yet figured out how to hide the DOS screen though.  Adding "No I-O" as part of the CALL "SYSTEM" command did not work.  Any suggestions?

Thanks again.

Marlene

0 Likes
Knowledge Partner
Knowledge Partner

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Yes, learning VBScript takes some time.  Fortunately, the web is full of examples for just about every possible thing you can imagine, so I 'learn' using search.

I am far from an expert on AcuCOBOL, having been associated with RM/COBOL my entire career, but it appears that C$SYSTEM (rather than SYSTEM) gives you access to the flags that can be used on Windows to cause a command to be run in a hidden window.  In particular, the flag CSYS-HIDDEN (value 32) seems correct.

My application is hosted by Business Information Server - that is, it is a browser based web application.  So the user never sees the window flash because the window is on the web server.  Just for the record, for any RM/COBOL user reading this, the SYSTEM window type is configurable by using the rmconfig registry configuration tool, or by CALLing C$GUICFG.


Tom Morrison
Consultant

0 Likes
Marlene Absent Member.
Absent Member.

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Thanks again, Tom.  Using C$SYSTEM for the call with the CSYS-HIDDEN flag set worked!

0 Likes
elopez Absent Member.
Absent Member.

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Tom, this suggestion works perfectly for me with smaller emails.  However the product I'm working with requires large-body emails to be sent out.  Since there is a limit to 1024 bytes in a command line, is there a way to use the vbscript differently to handle this?

Thanks,

Edgar

0 Likes
Marlene Absent Member.
Absent Member.

RE: Sending Email using Gmail and other newer protocols

Jump to solution

I had this exact problem.  I put the email body in a file and read the file in the VBScript.

Here is some of the code:

Const ForReading = 1

Dim emailObj, emailConfig

Dim fso, f , BodyText

Set fso = CreateObject("Scripting.FileSystemObject")

Set emailObj      = CreateObject("CDO.Message")

emailObj.To       = WScript.Arguments.Item(2)

emailObj.Subject  = WScript.Arguments.Item(3)

BodyText = fso.OpenTextFile(WScript.Arguments.Item(4),ForReading).ReadAll

emailObj.TextBody = BodyText

emailObj.From     = WScript.Arguments.Item(0)

Hope this helps.

Regards,

Marlene

0 Likes
Knowledge Partner
Knowledge Partner

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Hi Edgar,

Yes, in fact, as I mentioned above, my current script has a single parameter, which specifies the path of a configuration file.  All the other information is pulled from that configuration file.

Probably the least difficult approach is to specify the pathname of a file containing the message body and have the script read in the body.  You can find an example here (though he uses a constant for the pathname):
   http://www.paulsadowski.com/wsh/cdo.htm#LoadFromFile

Here is some code from an earlier version of my script (before I was using a configuration file):

Const forReading = 1
Dim objArgs, fso, theFile, strMessage, strBcc


Set objArgs = Wscript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")

strMessageFilename = objArgs(0)
strTo = objArgs(1)
strSubject = objArgs(2)
If objArgs.Count > 3 Then
 strBcc = objArgs(3)
Else
 strBcc = ""
End If

Set theFile = fso.OpenTextFile(strMessageFilename, forReading)
If theFile.AtEndOfStream Then
 strMessage = ""
Else
 strMessage = theFile.ReadAll
End If


As you can see, my arguments to this script were  <message-body-file> <To> <Subject> [<BCC>]. 

Hope this helps...

Tom Morrison
Hill Country Software


Tom Morrison
Consultant

0 Likes
Knowledge Partner
Knowledge Partner

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Wow, great minds think alike!   Or at least we were using the same examples...   Big Smile


Tom Morrison
Consultant

0 Likes
elopez Absent Member.
Absent Member.

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Marlene and Tom, thank you both for your prompt responses!  I have successfully implemented this and sent it off to QA. I really appreciate it.

0 Likes
elopez Absent Member.
Absent Member.

RE: Sending Email using Gmail and other newer protocols

Jump to solution

Hello.  I have a follow-up issue on this.  When I did the work and tested this, I was using the settings for gmail and everything processed smoothly.  However, additional testing was done by others using our Exchange Server.  I have the proper credentials (user, password, ip, port) but I keep getting the error "CDO.Message.1: The transport failed to connect to the server."  Any ideas on how to get around this?

0 Likes
Knowledge Partner
Knowledge Partner

RE: Sending Email using Gmail and other newer protocols

Jump to solution

While you have proper credentials, there are still settings on Exchange Server that could prevent the use of CDO.  Solving this will have to involve your server administrator.  Fortunately, you can run the VBScript without involving COBOL, so it should be easy to get the administrator's cooperation.


Tom Morrison
Consultant

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.