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
- Scott Gorke
- PowerBuilder
- Wednesday, 17 November 2021 17:57 PM UTC
- Page :
- 1
There are no replies made for this question yet.
However, you are not allowed to reply to this question.
However, you are not allowed to reply to this question.
* 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)
* 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.