Page 1 of 2
Error sending email
Posted: Thu Aug 10, 2023 11:02 pm
by chiaiese
Hi,
I have the following code to create emails:
Code: Select all | Expand
#define olMailItem 0 // A MailItem object.
METHOD Activate() CLASS TMail
local nCtr, cDest := ""
local olApp := CreateObject( "Outlook.Application" )
local olns, oMailItem
oMailItem := olApp:CreateItem(olMailItem)
oMailitem:Subject := ::cSubject
oMailitem:Body := ::cNoteText
for nCtr = 1 to len(::aRecipients)
cDest += ::aRecipients[nCtr]+"; "
next
oMailitem:to := cDest
cDest := ""
for nCtr = 1 to len(::aCC)
cDest += ::aCC[nCtr]+"; "
next
oMailitem:CC := cDest
for nCtr = 1 to len(::aFiles)
try
oMailItem:Attachments:Add(::aFiles[nCtr])
catch
msginfo("Impossibile allegare il file "+trim(::aFiles[nCtr]))
end
next
oMailItem:Display(.t.) // got error here!!!
return (Self)
I was using the above code for many years and with FW0709/xHarbour 1.1 it works without problems.
Now with FW20.02/Harbour 3.2 I get the following error:
Descrizione dell'errore: (DOS Error 1) WINOLE/1007 Parametro errato: DISPLAY
Stack Calls
===========
Called from TOLEAUTO:DISPLAY(0) ->
Called from TMAIL:ACTIVATE(151) -> .\wTMail.prg
Called from CLSSTADOC:GOMAIL(731) -> ..\prg\clsStado.prg
can somebody help to solve?
tank you
Roberto
Re: Error sending email
Posted: Fri Aug 11, 2023 11:45 am
by cmsoft
From what the description of the CreateItem object says in
https://learn.microsoft.com/en-us/offic ... createitem the display method does not take parameters.
Test
Re: Error sending email
Posted: Fri Aug 11, 2023 12:28 pm
by chiaiese
thank you for your answer but...
the parameter is optional, I also tried with no parameters, .t., .f., 0, 1, nothing changes.
Note that if I pass (.t.) the error appears 'after' I close the dialog, and if I pass (.f.) -non-modal mode- the error appears immediately after displayng the dialog, so the param seems to behave as expected
Syntax:
expression. Display( _Modal_ )
Parameters:
Modal Optional Variant True to make the window modal. The default value is False.
Roberto
Re: Error sending email
Posted: Fri Aug 11, 2023 1:05 pm
by Jimmy
hi,
as i know it is a Security Problem
try to start App as Admin and look what happens
Re: Error sending email
Posted: Fri Aug 11, 2023 1:17 pm
by karinha
Re: Error sending email
Posted: Fri Aug 11, 2023 2:45 pm
by chiaiese
Hi Karinha,
I tried your program, recompiled with FW20.02 and Harbour 3.2, and I get the same error on oEmail:Display( .T. )
thank you anyway
Roberto
Re: Error sending email
Posted: Fri Aug 11, 2023 3:24 pm
by karinha
chiaiese wrote:Hi Karinha,
I tried your program, recompiled with FW20.02 and Harbour 3.2, and I get the same error on oEmail:Display( .T. )
thank you anyway
Roberto
Roberto,
Sorry, I use [x]HARBOUR only. As soon as possible I try to test with Harbour.
Regards, saludos.
Re: Error sending email
Posted: Fri Aug 11, 2023 3:45 pm
by karinha
// HB.BAT - Roberto, con HARBOUR: Perfecto.
Code: Select all | Expand
@Echo Off
@Echo On
Cls
Echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
Echo ³ FiveWin For Harbour - Iniciando... Harbour Development Power ³Ü
Echo ³ (c) FiveTech, 1993-2020 For Microsoft Windows 95/98/NT/2000/ME And XP ³Û
Echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
Echo ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
Echo .
Echo Aguarde... Compilando os Modulos do Programa...
Set GT=gtgui
Set hdir=C:\HBBCC74
Set bcdir=C:\BCC74
Set fwhdir=C:\FwH1905
@If Exist *.Obj Del *.Obj
@If Exist *.Map Del *.Map
@If Exist *.TDS Del *.TDS
@If Exist *.Bc Del *.bc
@If Exist *.C Del *.C
@If Exist *.HC Del *.HC
If Exist OUTL2007.Exe Del OUTL2007.Exe
%hdir%\bin\harbour OUTL2007 /m/n /i%fwhdir%\include;%hdir%\include;%bcdir%\include /w0 /p > Erro.log 2> ERROS.LOG
%bcdir%\bin\bcc32 -M -c -v -O2 -eOUTL2007.Exe -I%hdir%\include -I%bcdir%\include OUTL2007.C >> Erro.log 2>> ERROS.LOG
If ErrorLevel 1 Type Erro.log | More
If ErrorLevel 1 Goto Exit
%bcdir%\bin\BRC32.Exe -R XPLOOK.RC
:ENDCOMPILE
%bcdir%\bin\ilink32 -aa -Gn -Tpe -s -v @HB.LNK
Echo .
IF ERRORLEVEL 1 GOTO LINKERROR
Cls
Echo .
Echo * Aplicacao Foi Desenvolvida Com Sucesso
Echo .
REM C:\PECOMPACT\PEC2 /NB /EMP:Y /TM:Y /CR:Y /MC OUTL2007.Exe
Echo .
OUTL2007
GOTO EXIT
:LINKERROR
PAUSE * Applicacao Nao Foi Desenvolvida Com Sucesso. Veja ERRO.LOG *
GOTO EXIT
Echo .
CLS
:EXIT
Regrads, saludos.
Re: Error sending email
Posted: Fri Aug 11, 2023 3:46 pm
by karinha
// HB.LNK - Roberto, Con HARBOUR: Perfecto.
Code: Select all | Expand
C:\BCC74\lib\c0w32.obj +
OUTL2007.obj, +
OUTL2007.exe, +
OUTL2007.map, +
C:\FWH1905\lib\FiveH.lib +
C:\FWH1905\lib\FiveHC.lib +
c:\HBBCC74\lib\hbwin.lib +
c:\HBBCC74\lib\gtgui.lib +
c:\HBBCC74\lib\hbrtl.lib +
c:\HBBCC74\lib\hbvm.lib +
c:\HBBCC74\lib\hblang.lib +
c:\HBBCC74\lib\hbmacro.lib +
c:\HBBCC74\lib\hbrdd.lib +
c:\HBBCC74\lib\rddntx.lib +
c:\HBBCC74\lib\rddcdx.lib +
c:\HBBCC74\lib\rddfpt.lib +
c:\HBBCC74\lib\hbsix.lib +
c:\HBBCC74\lib\hbdebug.lib +
c:\HBBCC74\lib\hbcommon.lib +
c:\HBBCC74\lib\hbpp.lib +
c:\HBBCC74\lib\hbcpage.lib +
c:\HBBCC74\lib\hbcplr.lib +
c:\HBBCC74\lib\hbct.lib +
c:\HBBCC74\lib\hbpcre.lib +
c:\HBBCC74\lib\xhb.lib +
c:\HBBCC74\lib\hbziparc.lib +
c:\HBBCC74\lib\hbmzip.lib +
c:\HBBCC74\lib\hbzlib.lib +
c:\HBBCC74\lib\minizip.lib +
c:\HBBCC74\lib\hbusrrdd.lib +
c:\HBBCC74\lib\hbcurl.lib +
c:\HBBCC74\lib\hbtip.lib +
c:\HBBCC74\lib\hbzebra.lib +
c:\HBBCC74\lib\libcurl.lib +
C:\XHBBCC74\Lib\png.Lib +
c:\bcc74\lib\cw32.lib +
c:\bcc74\lib\uuid.lib +
c:\bcc74\lib\import32.lib +
c:\bcc74\lib\ws2_32.lib +
c:\bcc74\lib\psdk\odbc32.lib +
c:\bcc74\lib\psdk\nddeapi.lib +
c:\bcc74\lib\psdk\iphlpapi.lib +
c:\bcc74\lib\psdk\msimg32.lib +
c:\bcc74\lib\psdk\psapi.lib +
c:\bcc74\lib\psdk\rasapi32.lib +
c:\bcc74\lib\psdk\gdiplus.lib +
c:\bcc74\lib\psdk\shell32.lib
Regards, saludos.
Re: Error sending email
Posted: Fri Aug 11, 2023 3:55 pm
by karinha
Imagen:
https://imgur.com/ATe9AVu
Regards, saludos.
Re: Error sending email
Posted: Fri Aug 11, 2023 4:40 pm
by chiaiese
Hi,
which version of Harbour do you use?
I used the same library list of your .lnk file and error is still there, just when I close the mail message dialog window (without sending).
Also, everytime I launch the program a new instance of Outlook is opened (but I think this is a minor issue
Roberto
Re: Error sending email
Posted: Fri Aug 11, 2023 4:45 pm
by karinha
chiaiese wrote:Hi,
which version of Harbour do you use?
I used the same library list of your .lnk file and error is still there, just when I close the mail message dialog window (without sending).
Also, everytime I launch the program a new instance of Outlook is opened (but I think this is a minor issue
Roberto
Code: Select all | Expand
Harbour 3.2.0dev (r2008190002)
Copyright (c) 1999-2020, https://harbour.github.io/
Syntax: c:\HBBCC74\bin\harbour.exe <file[s][.prg]|@file> [options]
Regards, saludos.
Re: Error sending email
Posted: Fri Aug 11, 2023 6:43 pm
by Rick Lipkin
This code works for me .... I send to Outlook 365 silently
Code: Select all | Expand
Try
oOutLook := TOleAuto():New("Outlook.Application")
Catch
Saying := "For some Odd reason The Outlook e-mail CLient failed to Initialize"
Msginfo( Saying )
Return(.f.)
End Try
oMailItem := oOutLook:Invoke("CreateItem", 0)
oMailitem:to := cTo
oMailitem:CC := cCC
oMailItem:Subject := cSubject
oMailItem:Body := cBody
Try
oMailItem:Attachments:Add("c:\dbtmp\"+cPdfName+".pdf" )
Catch
End Try
Try
oMailItem:display(.F.) // send silently
Catch
End Try
Try
oMailItem:Invoke("Send")
Catch
End Try
sysrefresh()
msginfo( "E-mail Sent" )
Rick Lipkin
Re: Error sending email
Posted: Sat Aug 12, 2023 4:02 pm
by Jimmy
hi,
as i can say it is not a Problem with Harbour, Fivewin or Outlook. it is Windows 10/11 vs. Windows 7
so the Question is : did somebody got it run under Windows 10/11 "as User"
Re: Error sending email
Posted: Sat Aug 12, 2023 5:13 pm
by karinha
Jimmy wrote:hi,
as i can say it is not a Problem with Harbour, Fivewin or Outlook. it is Windows 10/11 vs. Windows 7
so the Question is : did somebody got it run under Windows 10/11 "as User"
¿Estás seguro Jimmy de que es un problema de la versión de Windows?
Are you sure Jimmy this is a windows version problem?
Regards, saludos.