Hi,
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'
messu(tiedosto)
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
END IF
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
clipboard(osoite)
mail_item.Body = viestin_teksti
mail_item.Display
ole_attach = mail_item.Attachments
ole_attach.add(tiedosto)
//mail_item.Send
return 1
regards.