Send Emails from Fivewin application

Re: Send Emails from Fivewin application

Postby karinha » Wed May 15, 2024 1: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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Send Emails from Fivewin application

Postby FiveWiDi » Wed May 15, 2024 1: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 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1190
Joined: Mon Oct 10, 2005 2:38 pm

Re: Send Emails from Fivewin application

Postby paquitohm » Wed May 15, 2024 2: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
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Wed May 15, 2024 2:40 pm

I would prefer to not use external scripts as there is no control over the whole send operation.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Send Emails from Fivewin application

Postby paquitohm » Wed May 15, 2024 2: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.
Last edited by paquitohm on Wed May 15, 2024 2:46 pm, edited 1 time in total.
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby FiveWiDi » Wed May 15, 2024 2: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 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1190
Joined: Mon Oct 10, 2005 2:38 pm

Re: Send Emails from Fivewin application

Postby FiveWiDi » Wed May 15, 2024 2: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 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1190
Joined: Mon Oct 10, 2005 2:38 pm

Re: Send Emails from Fivewin application

Postby paquitohm » Wed May 15, 2024 2:52 pm

·
Last edited by paquitohm on Wed May 15, 2024 2:54 pm, edited 1 time in total.
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby paquitohm » Wed May 15, 2024 2: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
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Wed May 15, 2024 2: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.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Send Emails from Fivewin application

Postby karinha » Wed May 15, 2024 2:57 pm

Carlos, el comando no és este?

Code: Select all  Expand view  RUN

   ObjSendMail.DSNOptions = 14
 


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

Re: Send Emails from Fivewin application

Postby FiveWiDi » Wed May 15, 2024 4:02 pm

karinha wrote:Carlos, el comando no és este?

Code: Select all  Expand view  RUN

   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 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1190
Joined: Mon Oct 10, 2005 2:38 pm

Re: Send Emails from Fivewin application

Postby karinha » Wed May 15, 2024 7:10 pm

FiveWiDi wrote:
karinha wrote:Carlos, el comando no és este?

Code: Select all  Expand view  RUN

   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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Send Emails from Fivewin application

Postby karinha » Thu May 16, 2024 12:06 pm

Code: Select all  Expand view  RUN

// 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:

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

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

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

https://www.google.com/settings/security/lesssecureapps

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

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


#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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Thu May 16, 2024 12:13 pm

karinha wrote:
Code: Select all  Expand view  RUN
#pragma -w0
#pragma -es0


I didn't know it, thank you! :-)
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 64 guests