Error sending email

Error sending email

Postby chiaiese » Thu Aug 10, 2023 11:02 pm

Hi,
I have the following code to create emails:
Code: Select all  Expand view

#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
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 68
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: Error sending email

Postby cmsoft » Fri Aug 11, 2023 11:45 am

From what the description of the CreateItem object says in https://learn.microsoft.com/en-us/office/vba/api/outlook.application.createitem the display method does not take parameters.
Test
Code: Select all  Expand view
oMailItem:Display()
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Error sending email

Postby chiaiese » Fri Aug 11, 2023 12:28 pm

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
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 68
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: Error sending email

Postby Jimmy » Fri Aug 11, 2023 1:05 pm

hi,

as i know it is a Security Problem
try to start App as Admin and look what happens
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Error sending email

Postby karinha » Fri Aug 11, 2023 1:17 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error sending email

Postby chiaiese » Fri Aug 11, 2023 2:45 pm

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 Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 68
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: Error sending email

Postby karinha » Fri Aug 11, 2023 3:24 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error sending email

Postby karinha » Fri Aug 11, 2023 3:45 pm

// HB.BAT - Roberto, con HARBOUR: Perfecto.

Code: Select all  Expand view

@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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error sending email

Postby karinha » Fri Aug 11, 2023 3:46 pm

// HB.LNK - Roberto, Con HARBOUR: Perfecto.

Code: Select all  Expand view

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error sending email

Postby karinha » Fri Aug 11, 2023 3:55 pm

Imagen:

https://imgur.com/ATe9AVu

Image

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error sending email

Postby chiaiese » Fri Aug 11, 2023 4:40 pm

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
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 68
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: Error sending email

Postby karinha » Fri Aug 11, 2023 4:45 pm

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 view

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error sending email

Postby Rick Lipkin » Fri Aug 11, 2023 6:43 pm

This code works for me .... I send to Outlook 365 silently


Code: Select all  Expand view
 
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
User avatar
Rick Lipkin
 
Posts: 2618
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error sending email

Postby Jimmy » Sat Aug 12, 2023 4:02 pm

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" :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Error sending email

Postby karinha » Sat Aug 12, 2023 5:13 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 89 guests