1. Moshe Tangi
  2. PowerBuilder
  3. Monday, 24 February 2020 16:25 PM UTC

Hello

 

How do I send an email without any third party and no outlook installed on the machine just using

pb functions for define email address to , send from, file attach and so on ?

 

thanks

James Medick Accepted Answer Pending Moderation
  1. Tuesday, 21 April 2020 17:11 PM UTC
  2. PowerBuilder
  3. # 1

Totally over my head here.  I've never worked with non visuals objects.

I inserted the user objects on a window in my app through the insert/Object/UserObject menu but am at a loss as to what to try next.  Also, what type of variable is gn_smtp?

Comment
  1. Roland Smith
  2. Tuesday, 21 April 2020 20:00 PM UTC
The usual naming convention is that the first letter indicates scope followed by letters that indicate the datatype. A g is global which is added in the application painter like this:



n_smtp64 gn_smtp



I personally don't add non visuals like you did. Instead add it as an instance variable in the window:



n_smtp64 in_smtp



And then in your code refer to it like this:



in_smtp.of_SetSubject("The subject of the email")



Some people like to name non-visual variables with nv like this:



n_smtp64 inv_smtp



It is totally up to you, I use both naming styles.



Local variables which are defined in an event or function should start with an l (small L).



Examples:



Boolean lb_switch

Integer li_index

Long ll_count

String ls_title

  1. Helpful
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Tuesday, 21 April 2020 13:43 PM UTC
  2. PowerBuilder
  3. # 2

I moved the files into my main app but I cannot regenerate the u_tabpg_smtp object as it gives me the following error message:

---------- Compiler: Errors (8:39:27 AM)
emailsmtp_126.pbl(u_tabpg_smtp).cb_send.clicked.45: Error C0015: Undefined variable: gn_smtp

Comment
  1. Roland Smith
  2. Tuesday, 21 April 2020 14:35 PM UTC
u_tabpg_smtp is part of the example, you do not need it in your app. You only need n_winsock, n_smtp, and n_smtp64.
  1. Helpful
  1. Roland Smith
  2. Tuesday, 21 April 2020 14:37 PM UTC
Also, the example defines n_smtp/n_smpt64 as a global variable gn_smtp. In your app you can make it a local, instance or global variable, it is entirely up to you.
  1. Helpful
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Monday, 20 April 2020 20:46 PM UTC
  2. PowerBuilder
  3. # 3

Roland,

I've downloaded your PB emailsmtp64.pbl and placed it in my workspace.  When I set it as the current target, works great.  My question is, for us newbies, how do I incorporate it into an existing PB app? 

Comment
  1. Roland Smith
  2. Tuesday, 21 April 2020 00:04 AM UTC
That must be an old version, it is now named emailsmtp_126.pbl.



Copy n_winsock, n_smtp, and n_smtp64 into your application. Then use the Send button for coding example.
  1. Helpful
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 25 February 2020 09:11 AM UTC
  2. PowerBuilder
  3. # 4

Hi Moshe,

you can use the new C# Web API. I presented this solution at Elevate 2019, the PB client can call the Web API using HttpClient/RESTclient objects.

The presentation is called "PowerServer and C# Web API integration: Why, When, How" and the example based on SMTP for sending emails is at minute 28'15", slide 27.

You can watch it from "My Elevate" in your Appeon User Center, or from here.

Best,

.m

 

Comment
  1. Roland Smith
  2. Friday, 6 March 2020 16:17 PM UTC
Maybe it has improved recently but I heard that the SMTP class in .Net wasn't very good.
  1. Helpful
  1. Marco Meoni
  2. Friday, 6 March 2020 16:25 PM UTC
exactly, see here



https://www.infoq.com/news/2017/04/MailKit-MimeKit-Official/



In fact the presentations refers to the newer class.

Best,

.m
  1. Helpful
There are no comments made yet.
Andrew Barnes Accepted Answer Pending Moderation
  1. Monday, 24 February 2020 19:00 PM UTC
  2. PowerBuilder
  3. # 5

Does your PowerBuilder application connect to MS SQL Server?  If so, you could use SQL's sp_send_dbmail stored procedure.

 

Comment
  1. Moshe Tangi
  2. Tuesday, 25 February 2020 06:29 AM UTC
Yes it does , I will look into it ..thanks
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Monday, 24 February 2020 18:42 PM UTC
  2. PowerBuilder
  3. # 6

Agree with Roland,

PB app is not a mail server supporting standard mail protocols. Instead, lightweight send-mail can be done using SMTP access to an existing mail server. Roland's code examples are excellent source for code and for inspiration.

HTH /Michael

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 24 February 2020 16:32 PM UTC
  2. PowerBuilder
  3. # 7

You'll need to use SMTP which is a protocol to communicate directly with a mail server.

I have two different examples:

https://www.topwizprogramming.com/freecode_emailsmtp.html

https://www.topwizprogramming.com/pbnismtp.html

 

Comment
  1. Moshe Tangi
  2. Tuesday, 25 February 2020 06:29 AM UTC
Thanks Roland
  1. Helpful
  1. Moshe Tangi
  2. Friday, 6 March 2020 13:53 PM UTC
Hi Roland

Thanks a lot

The second option works fine for me
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.