FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Send Emails from Fivewin application
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 01:28 PM

Carlos, que yo recuerde, solo tiene un comando para LECTURA DE CONFIRMACIÓN. AVISO DE RECIBO, nunca lo vi.

Creo que esto es nuevo para los proveedores y creo que no han actualizado CDOSYS.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 01:57 PM
karinha wrote:Carlos, que yo recuerde, solo tiene un comando para LECTURA DE CONFIRMACIÓN. AVISO DE RECIBO, nunca lo vi.

Creo que esto es nuevo para los proveedores y creo que no han actualizado CDOSYS.

Regards, saludos.
Yo tengo entendido que hace muchas años que existe este indicador, pero se usa poco.

De todas maneras, los comandos/etiquetas como "Generate-Delivery-Report" se pueden agregar sin problemas y en el mail se pueden ver en las cabeceras.

Por ejemplo:
oMsg:Fields:Item( "urn:schemas:mailheader:Generate-Delivery-Report" ):Value = .T.
oMsg:Fields:Item( "urn:schemas:mailheader:Micampito-bonito" ):Value = "Vayaquesi."

Saludos

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:23 PM

Para mi el punto está en lo siguiente:

Harbour, también con CDOsys se ha quedado rezagado en cuestión de envio de emails

Antes de echar horas y horas (yo ya lo hice) de investigaciones infructuosas ¿ Qué tal probar con herramientas externas universales en Windows (Powershell) o propias de otros lenguajes (PHPMailer-PHP) o incluso trastear Python que está en la cresta de la ola de la innovación y así se matan dos pájaros de un tiro, máxime teniendo en cuenta que con cualquiera de las herramientas antes mencionadas, GPT te monta un ejemplo base y usable en un santiamén

Mis dos cents de euromail

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:40 PM

I would prefer to not use external scripts as there is no control over the whole send operation.

Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:44 PM

Which control is lost? I do not see that I have lost any control: I send a .ini file as a parameter and the external one generates an entry in that file letting me know if the sending has been successful or not and in case of error it records the description of the error. Powershell/PHP/Python all have recoverable error handling and can be recorded and returned

I don't see the loss of control

What is more worrying to me is the many hours I have dedicated to the topic of CDO using all the tricks on the web to conclude, after many hours, that CDO is not TLS compatible and that most likely hb_sendmail() is not compatible either.

Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:44 PM
Enrico Maria Giordano wrote:I would prefer to not use external scripts as there is no control over the whole send operation.
+1

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:47 PM
paquitohm wrote:Which control is lost? I do not see that I have lost any control: I send a .ini file as a parameter and the external one generates an entry in that file letting me know if the sending has been successful or not and in case of error it records the description of the error. Powershell/PHP/Python all have recoverable error handling and can be recorded and returned
I don't see the loss of control


What is more worrying to me is the many hours I have dedicated to the topic of CDO using all the tricks on the web to conclude, after many hours, that CDO is not TLS compatible and that most likely hb_sendmail() is not compatible either.
Tienes un ejemplo de cómo lo haces?

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:52 PM

·

Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:54 PM

En este mismo hilo comenté que mi archivo .ps1 de powershell para envio de email es "demasiado" avanzado para empezar, ademas de que me costaria trabajo limpiarlo y dejarlo claro.

A continuacion lo que hice fue preguntar a GPT por un ejemplo sencillo y lo pegué también en este mismo hilo, con ejemplo de llamada incluido.

Este tipo de cosas con GPT es tremendamente sencillo

Espero te sirva

PD 1. Tambien Mr. Otto puso un ejemplo de mail con PHP-Mailer. En mi caso prefiero powershell puesto que está instalado en la maquina, pero tampoco es demasiado inconveniente copiar el php.exe

PD 2. Si algunos recurrimos a esto no es por gusto, es porque Harbour no provee los medios. NO SE TRATA DE ESCOGER el gusto de cada uno: Que sea del propio lenguaje o no: No se puede escoger: El lenguaje no te provee de los insumos necesarios para enviar emails en condiciones (TLS) y hay que buscarse la vida: No hay dos opciones

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:55 PM
paquitohm wrote:Which control is lost? I do not see that I have lost any control: I send a .ini file as a parameter and the external one generates an entry in that file letting me know if the sending has been successful or not and in case of error it records the description of the error. Powershell/PHP/Python all have recoverable error handling and can be recorded and returned
I don't see the loss of control


What is more worrying to me is the many hours I have dedicated to the topic of CDO using all the tricks on the web to conclude, after many hours, that CDO is not TLS compatible and that most likely hb_sendmail() is not compatible either.
Ok. At the moment I'm happy with CDO (I don't need TLS). In the future, if needed, I will return to your sample, thank you.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 02:57 PM
Carlos, el comando no és este?
Code (fw): Select all Collapse
   ObjSendMail.DSNOptions = 14
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 04:02 PM
karinha wrote:Carlos, el comando no és este?
Code (fw): Select all Collapse
   ObjSendMail.DSNOptions = 14
Regards, saludos.
YYYYYYYYYYYYYYYEEEEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSSSS !!!!!

I LOVE YOU KARINHA !!!!!!!!!!!

oMsg := CREATEOBJECT( "CDO.Message" )
//Traza( 1, "ValType(oMsg)=", ValType(oMsg) )

oMsg:Configuration := oCfg
//Traza( 1, ":" )

IF !EMPTY( cSender )
cFrom := ["] + cSender + ["] + " <" + cFrom + ">"
//Traza( 1, ":" )
ENDIF

oMsg:DSNOptions := 14 /// <<<<<<<<<<<<<<<< AQUÍ ESTÁ !!!!!!

:P :P :P :P :P :P :P

VOY A CELEBRARLO !!!!!!

MUCHAS GRACIAS !!!!!!!

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Send Emails from Fivewin application
Posted: Wed May 15, 2024 07:10 PM
FiveWiDi wrote:
Carlos, el comando no és este?
Code (fw): Select all Collapse
   ObjSendMail.DSNOptions = 14
Regards, saludos.
YYYYYYYYYYYYYYYEEEEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSSSS !!!!!

I LOVE YOU KARINHA !!!!!!!!!!!

oMsg := CREATEOBJECT( "CDO.Message" )
//Traza( 1, "ValType(oMsg)=", ValType(oMsg) )

oMsg:Configuration := oCfg
//Traza( 1, ":" )

IF !EMPTY( cSender )
cFrom := ["] + cSender + ["] + " <" + cFrom + ">"
//Traza( 1, ":" )
ENDIF

oMsg:DSNOptions := 14 /// <<<<<<<<<<<<<<<< AQUÍ ESTÁ !!!!!!

:P :P :P :P :P :P :P

VOY A CELEBRARLO !!!!!!

MUCHAS GRACIAS !!!!!!!
GREAT!!!

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Send Emails from Fivewin application
Posted: Thu May 16, 2024 12:06 PM
Code (fw): Select all Collapse
// C:\FWH\SAMPLES\CDOSYS2.PRG - Simples MODEL for HARBOUR.

#include "FiveWin.ch"

FUNCTION Main()

   ...
   ...
   IF ...
      ...
      PW_EnviaEmail( mPwUser, mPwEmail, mPwNome, mPwPass )
      ...
   ENDIF
   ...
   ...

RETURN NIL
// Função para chamada do email:
FUNCTION PW_EnviaEmail( cPwUser, cPwEmail, cPwNome, cPwPass )

   LOCAL mRetorno := .T.

   // mail Simples nao responda
   cTo      := AllTrim( cPwEmail )
   cSubject := 'FiveWin:  Recuperação de Senha'
   lConf    := .T.
   lSSL     := .F.
   aFiles   := {} // pode ser uma matriz com vários endereços

   cMsg     := 'Simples Informática e Consultoria Ltda'
   cMsg     += CRLF + 'Sistema de Contabilidade Pública' + CRLF
   cMsg     += CRLF + 'Recuperação de Senha do Usuário:'
   cMsg     += CRLF + 'Nome: '     + cPwNome
   cMsg     += CRLF + 'Usuário: '  + cPwUser
   cMsg     += CRLF + 'Senha: '    + cPwPass
   cMsg     += CRLF + 'Email: '    + cPwEmail

   mRetorno := Envia_Email( aFiles, cSubject, cTo, cMsg, mEmailServer, ;
      mEmailFrom, mEmailUser, mQwer, mEmailPorta, '', '', lCONF, lSSL )

RETURN( mRetorno )

// Função de chamada do CDOSys:

/*
[url]http://www.pctoledo.com.br/forum/viewtopic.php?f=4&t=10764&start=30[/url]

[url]http://www.pctoledo.com.br/forum/viewtopic.php?f=2&t=16294&start=15[/url]

[url]http://fivewin.com.br/index.php?/topic/26829-erro-ao-enviar-e-mail-via-cdomessage-e-gmail/#comment-278073[/url]

[url]https://www.google.com/settings/security/lesssecureapps[/url]

[url]https://www.usandoaccess.com.br/tutoriais/enviar-email-usando-o-cdosys.asp[/url]

[url]https://stackoverflow.com/questions/3791461/cdo-message-wont-send-when-delivery-receipt-requested[/url]
*/

#pragma -w0
#pragma -es0

FUNCTION Envia_email( aFiles, cSubject, cDest, cMsg, cServerIp, cFrom, cUser, ;
                      cPass, vPORTSMTP, cCC, cBCC, vEMAIL_CONF, wSSL_EMAIL )

   LOCAL lRet := .F.
   LOCAL oCfg, oError, oMsg
   LOCAL lAut := .T.

   TRY
      oCfg := CREATEOBJECT( "CDO.Configuration" )

      WITH OBJECT oCfg:Fields

      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver"             ):Value := cServerIp   // server SMTP
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport"         ):Value := vPORTSMTP
      :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing"              ):Value := 2           // Remote SMTP = 2, local = 1
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"       ):Value := 1           //
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl"             ):Value := .F. // wSSL_EMAIL  // .F. Ou .T.
      :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername"           ):Value := AllTrim( cUser )
      :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword"           ):Value := AllTrim( cPass )
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"  ):Value := 60

      :Update()

   END WITH

   lRet := .T.

   CATCH oError

      MsgStop( "Não Foi possível Enviar o e-Mail!"  + hb_osNewLine() + ;
               "Error: "     + Transform( oError:GenCode,   nil ) + ";" + hb_osNewLine() + ;
               "SubC: "      + Transform( oError:SubCode,   nil ) + ";" + hb_osNewLine() + ;
               "OSCode: "    + Transform( oError:OsCode,    nil ) + ";" + hb_osNewLine() + ;
               "SubSystem: " + Transform( oError:SubSystem, nil ) + ";" + hb_osNewLine() + ;
               "Mensaje: "   + oError:Description, "Atenção" )

   END

   IF lRet

      TRY

         oMsg := CREATEOBJECT ( "CDO.Message" )

         WITH OBJECT oMsg

            :Configuration := oCfg
            :FROM          := cUser // cFrom
            :Sender        := cUser // :Sender = "kapaiabafwh@gmail.com"
            :TO            := cDest
            :Subject       := cSubject
            :TextBody      := cMsg

            FOR x := 1 TO Len( aFiles )

               :AddAttachment( AllTrim( aFiles[ x ] ) )

            NEXT

            :MDNRequested  := .T. // Requiere respuesta
            :DSNOptions    := 14  // Return a DSN if delivery succeeds, fails, or is delayed.


            // :Fields( "urn:schemas:mailheader:disposition-notification-to" ):Value   := cFrom //'retorno@simplesinformatica.com.br'
            // :Fields( "urn:schemas:mailheader:return-receipt-to" ):Value             := cFrom //'retorno@simplesinformatica.com.br'

            :Fields( "urn:schemas:httpmail:importance" ):Value                      := '2'
            :Fields:update()

            :Send()

      END WITH

      lRet := .T.

      CATCH oError

         msg := 'Não Foi Possível Enviar a Mensagem: "' + cSubject + '"' + CRLF
         msg += 'Verifique se existe conexão com a Internet.' + CRLF
         msg += "Destinatário.: " + cDest                     + CRLF
         msg += "Error.:     "  + Str( oError:GenCode )       + CRLF
         msg += "SubC.:      "  + Str( oError:SubCode )       + CRLF
         msg += "OSCode.:    "  + Str( oError:OsCode )        + CRLF
         msg += "SubSystem.: "  + oError:SubSystem            + CRLF
         msg += "Mensagem.:  "  + oError:Description          + CRLF
         msg += "Operação.: ["  + oError:Operation + "]"      + CRLF

         mArgs := oError:Args
         msg += "Argumento: " + ValType( mArgs ) + '[' + AllTrim( Str( Len( mArgs ) ) ) + ']' + CRLF

         IF ValType( mArgs ) = 'C'

            msg += "Argumento: [" + mArgs + "]"

         ELSEIF ValType( mArgs ) = 'A'

            FOR i = 1 TO Len( mArgs )

               msg += Str( i, 1 ) + " [" + mArgs[ i ] + "]" + CRLF

            NEXT

         ENDIF

         MsgInfo( msg )

         lRet := .F.

      END

   ENDIF

   oCfg := NIL
   oMsg := NIL

RETURN( lRet )

// FIN / END
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Send Emails from Fivewin application
Posted: Thu May 16, 2024 12:13 PM
karinha wrote:
Code (fw): Select all Collapse
#pragma -w0
#pragma -es0
I didn't know it, thank you! :-)

Continue the discussion