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