1. Sathishkumar S
  2. PowerBuilder
  3. Thursday, 5 October 2023 12:23 PM UTC

Hi All,

 

I have tried implementing SMTPclient in PB2022 R2 whereas I am able to send an email using SendAsync() but how to check the email status like queue/sending/sent/failed/cancelled

below is the example code I have used

Long ll_handle
n_smtpclient inv_SmtpClient

inv_SmtpClient = CREATE n_smtpclient

//set the email account information
inv_SmtpClient.Host = "smtp.gmail.com"
inv_SmtpClient.Port = 587
inv_SmtpClient.Username = "tester001.appeon@gmail.com"
inv_SmtpClient.password = "Mypassword001"
inv_SmtpClient.EnableTLS = True

//set the email message
inv_SmtpClient.Message.SetSender("tester001.appeon@gmail.com","Tester001")
inv_SmtpClient.Message.AddRecipient("tester002.appeon@gmail.com")
inv_SmtpClient.Message.Subject = "SMTPClient Test Message"
inv_SmtpClient.Message.TextBody = "SMTPClient example message body"

//send the email message asynchronously
ll_handle = inv_SmtpClient.SendAsync()

I would like to know how to get the status of the email.

Regards
Sathishkumar

Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 5 October 2023 12:33 PM UTC
  2. PowerBuilder
  3. # 1

Hi.

I think you have to code the onsendfinished event.

To do that you will have to create a object that inherits from smtpclient standard class. Then you will be able to code that event.

Andreas.

Comment
  1. Sathishkumar S
  2. Thursday, 5 October 2023 12:52 PM UTC
Hi Andreas,



I have tried using onsendfinished event, but unable to get the status like queue/sending/sent/failed/cancelled

Sent success is 1

failed are negative numbers

I am looking for other status like queue/sending/cancelled



Regards

Sathishkumar



  1. Helpful
  1. Andreas Mykonios
  2. Thursday, 5 October 2023 13:04 PM UTC
I believe it's up to you to build a queue with all pending mails (send using sendasync). You need to store in that queue every email handle. Then when onsendfinished occurs you have to do some processing in your queue. An email should be cancelled when you call sendasynccancel with a return value = 1. An email is considered as sent when you get 1 for its handle in onsendfinished event. If you don't cancel it or didn't get any notification from onsendfinished for that specific handle you should consider it as being queued to be sent.

Andreas.
  1. Helpful
  1. Sathishkumar S
  2. Thursday, 5 October 2023 14:59 PM UTC
Hi Andreas



Thank you, I will try to implement it, if there is any help documents available kindly suggest, as far I checked I couldn't find any document about the status related working arounds or similar.



Regards

Sathishkumar.
  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.