1. Don Whitehead
  2. PowerBuilder
  3. Wednesday, 26 January 2022 22:43 PM UTC

We converted an application from version 8 to Powerbuilder 2021 and the following code is not functioning properly..

The code actually works fine when I run it locally using the PowerBuilder 20221 IDE, but when I build the .exe it is giving us a -3 return code when trying to execute the oSMTP.ConnectToNewObject("SMTPEmail.clsEmail") command

string ls_from
string ls_replyto = ""
string ls_to
string ls_cc
string ls_bcc
string ls_subject
string ls_body
boolean lb_DisplayEmail = true
string ls_attachments[]
integer li_rc
oleobject oSMTP
oleobject oLDAP
oSMTP = CREATE oleobject
li_rc = oSMTP.ConnectToNewObject("SMTPEmail.clsEmail")
//MessageBox("return code from connect to new object",li_rc)

oLDAP = CREATE oleobject
li_rc = oLDAP.ConnectToNewObject("SMTPEmail.clsLDAP")

oSMTP.EmailSpellCheckEnabled=TRUE
oSMTP.EmailWindowModal=TRUE

// dont allow as_to to be null
if isnull(as_to) then
as_to = ""
end if

ls_to = as_to
ls_replyto = ""
ls_cc = as_cc
ls_bcc = as_bcc
ls_subject = as_subject
ls_body = as_body

// CHG0032612 if fromn address is passed use it
if as_from = "" then
ls_from = oLDAP.GetLDAPUserEmail(gs_initial_user)
else
ls_from = as_from
end if

ls_bcc = ls_bcc + ls_from // always bcc yourself to make up for the "no sent" issue


ls_attachments[1] = as_attach


//oSMTP.EmailWindowTitle = "PowerBuilder test" // puts a custom title on the email window
oSMTP.EmailFromEnabled = False

// w16249 add email server name as an ini entry
oSMTP.EmailSMTPServer = ProfileString( gs_profile,"email","SMTPServer", "mailhost.empire.ca")

oSMTP.EmailFormat = oSMTP.oSMTPConstants.FormatTEXT // use the dll's allowable values for the email format

oSMTP.SendEmail (ls_from, ls_to, ls_replyto, ls_cc, ls_bcc, ls_subject, ls_body, lb_DisplayEmail, ls_attachments[])

destroy oSMTP
destroy oLDAP

Don Whitehead Accepted Answer Pending Moderation
  1. Thursday, 27 January 2022 01:13 AM UTC
  2. PowerBuilder
  3. # 1

Thank you for the response John.. 32 bit was the correct compile..much appreciated

Comment
  1. John Fauss
  2. Thursday, 27 January 2022 04:47 AM UTC
Happy to help, Don! Would you please mark this question as resolved? Thanks!
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 27 January 2022 00:00 AM UTC
  2. PowerBuilder
  3. # 2

Hi, Don -

From the tags you assigned to this question, it appears the exe/pbd's are deployed as 64-bit?

Do you have a 64-bit version of the OCX installed on the machine where the 64-bit app is running?

For testing purposes, can you try building a 32-bit exe/pbd's to see if that works?

Regards, John

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.