1. Scott Gorke
  2. PowerBuilder
  3. Wednesday, 17 November 2021 17:57 PM UTC

We have a 24/7 PB2019R2 app that pulls records off a queue table, saves some data in a PowerSoft Report format (<filename>.PSR), then calls this code to email the PSR file as an attachment. Problem is at one client, the call to log off the mail session hangs. This doesn't seem to happen anywhere else. Any ideas on what to do from here? Thanks in advance...



<.......Call function - pass in the recipient's email address.......>

str_mail                lstr_mail
mailRecipient     mrecip

<.......Generate PSR file.......>

//Establish an instance of the Mail Session object, and log on
lstr_mail.mSes = create mailSession
lstr_mail.mRet = lstr_mail.mSes.mailLogon ()    //here, we have an instance of MS Outlook running alongside our 24/7 app
if lstr_mail.mRet <> mailReturnSuccess! then
    f_logoff_mail(lstr_mail.mSes )
        return 3
end if

// Attach PSR File to mail message
lstr_mail.mAttach.FileType = mailAttach!
lstr_mail.mAttach.PathName = ls_filename
lstr_mail.mAttach.FileName = ls_filename
lstr_mail.mMsg.Subject = <.......subject.......>
lstr_mail.mMsg.NoteText = " "
lstr_mail.mAttach.Position = len(lstr_mail.mMsg.NoteText)-1
lstr_mail.mMsg.AttachmentFile[1] = lstr_mail.mAttach
    
mrecip.Name = as_address    
lstr_mail.mRet = lstr_mail.mSes.MailResolveRecipient(mrecip)
if lstr_mail.mRet <> mailReturnSuccess! then
    f_logoff_mail(lstr_mail.mSes )
    return 4
end if

lstr_mail.mMsg.Recipient[1] = mrecip

lstr_mail.mRet = lstr_mail.mSes.Mailsend( lstr_mail.mMsg )
if lstr_mail.mRet <> mailReturnSuccess! then
    f_logoff_mail(lstr_mail.mSes )
    return 5
end if

// destroys mail session
lstr_mail.mSes.mailLogoff ( )    //HANGS HERE
<.......>
return 1

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 17 November 2021 18:30 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Scott;

  We have had a few customers where the PB App Logs IN and Out of the Mail Server for each interaction. That has caused similar issues in some cases as you described. However, changing these PB Apps so that they only Login to the Mail Server once at start-up and then logoff once at closure cured this problem.

Regards ... Chris

Comment
  1. Scott Gorke
  2. Wednesday, 8 December 2021 13:40 PM UTC
Update: I have since discovered these:



* the app will hang on its first email in the queue table......if our app is on PB 2019 R2, and the mail client is Outlook 2016 32-bit

* the app will error out on every email....if our app is on PB 2019 R2, and the mail client is Outlook 2016 64-bit (The error says "Either there is no default mail client or the current email client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client."

* the app in an earlier release (but same code) on PB 2012 works just fine (Outlook 2016 32-bit)
  1. Helpful
  1. Scott Gorke
  2. Tuesday, 21 December 2021 16:40 PM UTC
OK, I think my team has it figured out:

* instead of creating and destroying the mail session every time, we create the mail session once (at start), and destroy it once (at closure of app)

* there seems to have been a change in PB 2019 R3 in which you have to assign the email address to the mail session's "Address" field, and not to its "Name" field. We used to assign the email address to the mail session's "Name" field, and the MailResolveRecipient function would work, whereas now it doesn't anymore. Code sample:



//mrecip.Name = as_address

//mrecip.Name = 'Clown,Bozo J'

//mrecip.Address = 'bozojclown@a.com'

mrecip.Name = as_name

mrecip.Address = as_address



lstr_mail.mRet = lstr_mail.mSes.MailResolveRecipient(mrecip)



Thanks to all who contributed to this Q&A.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Tuesday, 21 December 2021 17:30 PM UTC
Thanks for sharing the solution!
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 18 November 2021 06:51 AM UTC
  2. PowerBuilder
  3. # 1

Hi Scott,

Its a know issue. I had similar problems. I've commented out the call to mailLogoff function and have not seen any side effects.

HTH,

René

 

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