1. Ed Sudit
  2. PowerBuilder
  3. Tuesday, 1 October 2024 02:57 AM UTC

I am trying to change my code from using the PBNISMTP library to the built-in SMTPClient object with the latest version of PowerBuilder 2022 R3 build 3391.  The PBNISMTP library works fine when I run it through the IDE but the compiled version crashes with a fatal error.  Changing the code to SMTPClient causes a timeout Error.

The SMTPClient settings are pretty vanilla where I am using an SSL connection with port 465, but there is no equivalent in the SMTPClient class, at least not one I can see.

Can someone help with this?

Thanks,
Ed

Who is viewing this page
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 2 October 2024 06:07 AM UTC
  2. PowerBuilder
  3. # 1

Hi.

Two points I would try, if you haven't already. Remove the attachment... Try to send an email as simple as possible. While you are mentioning that SecureProtocol value doesn't matter (you probably checked all values), I would set it to 0 for my tests... Also I would try to set a timeout of 0...

Andreas.

Comment
There are no comments made yet.
Ed Sudit Accepted Answer Pending Moderation
  1. Wednesday, 2 October 2024 01:52 AM UTC
  2. PowerBuilder
  3. # 2

Hello John,

Thank you for your reply.  I added the log feature but it offers a small amount of help.  It does confirm the fact that the connection is made, but it still times out.  Here is the log:

Trying 66.39.3.114:465...
Connected to kaufmansrs.mail.pairserver.com (66.39.3.114) port 465
Operation timed out after 30005 milliseconds with 0 bytes received
Closing connection
Closing connection
Error Info: Timeout was reached
End Connnect: 2024-10-01 21:41:08

==================================================================================

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 1 October 2024 21:41 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Ed -

The -11 is a timeout error. Have you tried using the LogFile feature of the SMTPClient object to see if it gives you some additional information?

// Enable the logging feature.
lnv_SmtpClient.LogFile("c:\mail.log")

I found this in the PB 2022 R3 Application Techniques publication, "Using SMTP", in example 2:

    https://docs.appeon.com/pb2022r3/application_techniques/Using_SMTP.html

Curiously, the LogFile property is not listed in the PB Help topic for SMTPClient.

* * * Edit * * *
LogFile is a function of the SMTPClient object, not a property. It is documented in PB Help.

Best regards, John

Comment
There are no comments made yet.
Ed Sudit Accepted Answer Pending Moderation
  1. Tuesday, 1 October 2024 20:57 PM UTC
  2. PowerBuilder
  3. # 4

Do you see anything in the settings that would cause the -11 error?  PBNISMTP used to work fine with the previous build of PowerBuilder.  It actually still works but only when I run the application from the IDE.  I would rather use the SMTP class from PowerBuilder.

Thank you in advance,

Ed

Comment
There are no comments made yet.
Ed Sudit Accepted Answer Pending Moderation
  1. Tuesday, 1 October 2024 13:25 PM UTC
  2. PowerBuilder
  3. # 5

This is my code:

integer li_rc
SMTPClient lnv_SmtpClient
lnv_SmtpClient = CREATE SMTPClient

lnv_SmtpClient.Host = "my.mailserver.com"
lnv_SmtpClient.Port = 465
lnv_SmtpClient.Username = "MyUser@mailserver.com"
lnv_SmtpClient.password = "mypassword"
lnv_SmtpClient.SetProxy("",0)
lnv_SmtpClient.EnableTLS = True;  //False or True returns the same result
lnv_SmtpClient.SecureProtocol = 1  //Regardless of the value the result is the same
lnv_SmtpClient.Timeout = 30

lnv_SmtpClient.Message.SetSender("myuser@mailserver.com", "user name");
lnv_SmtpClient.Message.AddRecipient("myfriend@gmail.com", "friend name");

lnv_SmtpClient.Message.Subject = "Subject of my email"
lnv_SmtpClient.Message.HTMLBody = "Body of my email"
lnv_SmtpClient.Message.Priority = 0 //Normal
lnv_SmtpClient.Message.AddAttachment("c:\temp\myattachment.pdf")
lnv_SmtpClient.Message.Encoding = "UTF-8"

// send the email
li_rc = lnv_SmtpClient.Send()

 

****  Result is that li_rc is -11

 

As for the pbnismpt question, I compile to x32 but I believe it's the same error with x64.

Comment
  1. Bruce Armstrong
  2. Tuesday, 1 October 2024 14:47 PM UTC
Off the top of my head this line looks weird:



lnv_SmtpClient.SetProxy("",0)



If you're not providing a value, don't make the call.
  1. Helpful
  1. Ed Sudit
  2. Tuesday, 1 October 2024 14:49 PM UTC
This is to disable the proxy. I was trying different settings. This didn't make a difference.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 1 October 2024 05:59 AM UTC
  2. PowerBuilder
  3. # 6

Hi.

Not sure I understand your issue. Can you provide an example of the settings you want to use in smtpclient?

As for pbnismtp, is your executable x32 or x64?

Andreas.

Comment
  1. Ed Sudit
  2. Tuesday, 1 October 2024 14:48 PM UTC
This is my code:



integer li_rc

SMTPClient lnv_SmtpClient

lnv_SmtpClient = CREATE SMTPClient



lnv_SmtpClient.Host = "my.mailserver.com"

lnv_SmtpClient.Port = 465

lnv_SmtpClient.Username = "MyUser@mailserver.com"

lnv_SmtpClient.password = "mypassword"

lnv_SmtpClient.SetProxy("",0)

lnv_SmtpClient.EnableTLS = True; //False or True returns the same result

lnv_SmtpClient.SecureProtocol = 1 //Regardless of the value the result is the same

lnv_SmtpClient.Timeout = 30



lnv_SmtpClient.Message.SetSender("myuser@mailserver.com", "user name");

lnv_SmtpClient.Message.AddRecipient("myfriend@gmail.com", "friend name");



lnv_SmtpClient.Message.Subject = "Subject of my email"

lnv_SmtpClient.Message.HTMLBody = "Body of my email"

lnv_SmtpClient.Message.Priority = 0 //Normal

lnv_SmtpClient.Message.AddAttachment("c:\temp\myattachment.pdf")

lnv_SmtpClient.Message.Encoding = "UTF-8"



// send the email

li_rc = lnv_SmtpClient.Send()







**** Result is that li_rc is -11







As for the pbnismpt question, I compile to x32 but I believe it's the same error with x64.
  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.