1. Hannu Pikkarainen
  2. PowerBuilder
  3. Tuesday, 22 November 2022 17:05 PM UTC


I have created an application for a customer, that sends email through users Outlook. It has worked without problems for years.

For some time ago we switched the distribution of the application into Cloud App launcher model. Works fine.

Now we have discovered one problem. Sending email fails when application tries to add an attachment to the email (ole_attach.add(tiedosto)).

If I distribute application traditionally copying all necessary files in one directory on customers laptop sending email works fine. Application is 32-bit and Outlook is 32 or 64-bit, it does not matter.

Here is my example code:

tring tiedosto , polku
long vastaus
N_cst_filesrv inv_filesrv1
f_SetFileSrv(inv_filesrv1, TRUE)
polku = inv_filesrv1.of_GetCurrentDirectory()
tiedosto = polku + '\' + 'Info_to_be_checked_' + string(nro) + '.pdf'
vastaus = dw_2.SaveAs(tiedosto,PDF!,true)
if isnull(tiedosto) then
tiedosto = 'Saving PDF-file failed'
Messu(string(vastaus) + ' ' + tiedosto)
return 0
end if

OLEObject ole_outlook , ole_attach

Integer retval
Boolean WasOpen

ole_outlook = CREATE OLEObject
retval = ole_outlook.ConnectToObject("","outlook.application")
if retval <> 0 then
retval = ole_outlook.ConnectToNewObject("outlook.application")
end if

IF retval <> 0 THEN
MessageBox ("Mail", 'Login into mail failed')
return 0
OleObject mail_item

mail_item = ole_outlook.Createitem(0)

mail_item.Subject = 'Info to be checked'

if pos(osoite,'@') = 0 then
messagebox('Error','Can't send email cause receiver does not have an emailadress')
return 0
end if

mail_item.To = osoite

mail_item.Body = viestin_teksti

ole_attach = mail_item.Attachments


return 1



Hannu Pikkarainen Accepted Answer Pending Moderation
  1. Friday, 30 June 2023 14:44 PM UTC
  2. PowerBuilder
  3. # 1


The problem was caused by the fact that PDF was saved with old way that needs PS Datawindow-printer installed on the workstation. I changed the method to Native PDF and it solved the problem.

BR, Hannu

There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 22 November 2022 17:21 PM UTC
  2. PowerBuilder
  3. # 2

Hi Hannu;

   The PB runtime is the exactly same as a native EXE when executed as either a PowerClient or PowerServer based app through the CAL. I suspect (guessing) that the issue might be either a Windows "policy", antivirus or insufficient execution privileges that is blocking your App from Outlook.

Just, Food for thought.

Regards ... Chris 


  1. Miguel Leeuwe
  2. Wednesday, 23 November 2022 09:30 AM UTC
If I'm not wrong, there's one difference when using powerclient: Your distributed folders have to be subfolders of the application folder. Check where the application (in which folder) is checking for the attachments.

  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.