FAQ: How can I send SMTP from PowerBuilder
PowerBuilder’s only native method of sending email is through Simple MAPI, which is very limited. In particular, the approach was hampered quite a bit when Microsoft introduced security enhancements which resulted in security warnings being generated anytime Simple MAPI was used.
The most popular approach for addressing this has been to use SMTP to send email instead. There are quite a number of third party tools that can be used to accomplish this:
- Topwiz Software’s EmailSMTP is a PowerBuilder non-visual user object that uses Windows API calls to send SMTP.
- PBNISMTP is an open source PowerBuilder extension (PBNI) written in C++ that wraps the open source CPJNSMTPConnection class to send SMTP.
- This blog post explains how to create a .Net assembly that can then be wrapped via a COM Callable Wrapper and called from Classic PowerBuilder. The blog article uses Visual Studio and C# to create the assembly, but the assembly could also be created using PowerBuilder.Net. The STMPClient.zip file in these PowerBuilder Samples on Google Drive is an example of doing just that.
- There are third party ActiveX controls that can be used to generate SMTP email, such as the Mail for Active X control from Dart.
- Many databases have build in features for sending email such as SQL Anywhere’s xp_startsmtp / xp_sendmail, Oracle’s UTL_SMTP or UTL_MAIL, Microsoft SQL Server’s Database Mail, etc. Therefore, it is quite feasible to create a stored procedure in the database that handles email transmission and simply have the PowerBuilder client invoke that.
Always respect your knowledge and insights. For this topic your within the context of a controlled corporate environment? I mean you would not send emails directly accessing a customer's server if your software was sold commercially.
I don't see the issue. We have one commercial app where we use PBNISMTP. We give the admin users (employees of the customer) a configuration screen where they enter the email configuration information for their servers. They're sending email from the app to their users (mostly reports that we generate into Excel spreadsheets and then email). Another commercial app uses the database package approach. We have admin screens (once again used by customer employees) that enter the email configuration information that the app will use to send email to other customer employees).
We use mailsend, an open source command line tool which supports IPv6, with TopWiz's RunandWait to launch it.
Thanks for the FAQ.
Also check this out: DWCFilter: PowerBuilder Components - SMTP Library
We created a utility in C# and then were able to call that assembly from within PowerBuilder.
I download the Topwiz software EmailSMTP, but when I execute the example I have the next SendMailError message:
An attempt was made to access a socket in a way forbidden by its acces permissions.
I have in Settings an internal SMTP relay server with the port 25 and not require user an password.
What I'm doing wrong?