Send Emails from Fivewin application

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Tue May 14, 2024 3:11 pm

paquitohm wrote:CDO does not allow sending from accounts with the SSL protocol,


This is not true. I'm using CDO with SSL without problems.
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 » Tue May 14, 2024 3:51 pm

Hello Ruth. I don't use it anymore. I don't remember exactly, but I think it caused problems for customers and I removed it from the line. I don't remember how to do it anymore. I am really sorry.

Hola Rut. Ya no lo uso. No lo recuerdo exactamente, pero creo que causó problemas a los clientes y lo eliminé de la línea. Ya no recuerdo cómo hacerlo. Lo siento mucho.

Look this:

https://forums.fivetechsupport.com/viewtopic.php?f=6&t=13175&p=142165&hilit=imagen+en+el+email#p142165

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

Re: Send Emails from Fivewin application

Postby paquitohm » Tue May 14, 2024 4:03 pm

Enrico Maria Giordano wrote:
paquitohm wrote:CDO does not allow sending from accounts with the SSL protocol,


This is not true. I'm using CDO with SSL without problems.



sorry, I meant TLS
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Tue May 14, 2024 4:34 pm

paquitohm wrote:sorry, I meant TLS


It should work, but I never checked it myself. Do you have any sample (with userid and password) that you can share (at least with me), so I can test it here?
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 NWKL » Tue May 14, 2024 5:21 pm

What is the working solution to send emails with FWH? that works with or without Outlook installed and accepts attachments and any protocols?

thanks
NWKL
 
Posts: 26
Joined: Thu Aug 04, 2022 12:45 pm

Re: Send Emails from Fivewin application

Postby paquitohm » Tue May 14, 2024 5:35 pm

Enrico Maria Giordano wrote:
paquitohm wrote:sorry, I meant TLS


It should work, but I never checked it myself. Do you have any sample (with userid and password) that you can share (at least with me), so I can test it here?


In his day I already hit him too many heads to prepare a test now. I came out of that very fed up and saw that Harbour is not up to par in terms of emails. That everyone suggests hb_sendmail() but they have not tried it and that the development of this in harbour currently and in the future will always leave something to be desired. So I chose to do it with a universal Windows, without installations, third party tool: powershell

In my case I send from an outlook account on port 587 using TLS
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Tue May 14, 2024 5:37 pm

NWKL wrote:What is the working solution to send emails with FWH? that works with or without Outlook installed and accepts attachments and any protocols?

thanks


There are more than one posibilities. Personally, I'm still using CDO.
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 Enrico Maria Giordano » Tue May 14, 2024 5:47 pm

paquitohm wrote:In my case I send from an outlook account on port 587 using TLS


Sounds interesting. Can you share a sample, please?
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 » Tue May 14, 2024 5:57 pm

In my case I used ChatGPT to learn PowerShell. It helped me create a .ps1 file which I finally called from harbour.
An .ini file is generated as input and that same file is modified, recording whether or not the sending has been possible.
My .ps1 process is really complex. I would have to clean it a little, it's not exactly easy. IMHO it would help more to ask Chat GPT for a simple example, but regardless, you should. He still wants it, later I can clean it and paste it in the forum, but of course I would also require an example of a call. It's really a job
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby paquitohm » Wed May 15, 2024 6:49 am

Enrico Maria Giordano wrote:
paquitohm wrote:In my case I send from an outlook account on port 587 using TLS


Sounds interesting. Can you share a sample, please?



From ChatGPT, simple sample:

Code: Select all  Expand view  RUN

# script1.ps1
# Definir los parámetros
$CorreoDe = "tu_correo@outlook.com"
$CorreoPara = "correo_destino@example.com"
$Asunto = "Asunto del correo"
$Cuerpo = "Cuerpo del correo"
$SMTPServer = "smtp-mail.outlook.com"
$SMTPPort = 587
$Credenciales = Get-Credential -Message "Por favor, introduce tu correo y contraseña"

# Crear el objeto de correo
$Correo = New-Object System.Net.Mail.MailMessage($CorreoDe, $CorreoPara, $Asunto, $Cuerpo)

# Crear el objeto SMTP
$SMTP = New-Object Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$SMTP.EnableSsl = $true
$SMTP.Credentials = New-Object System.Net.NetworkCredential($Credenciales.UserName, $Credenciales.Password);

# Enviar el correo
$SMTP.Send($Correo)



Code: Select all  Expand view  RUN
FUNCTION Main()
   LOCAL cCommand

   // Define el comando para ejecutar el script de PowerShell
   cCommand := "powershell.exe -File C:\ruta_a_tu_script\script1.ps1"

   // Llama al comando
   Run (cCommand)
RETURN
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

Re: Send Emails from Fivewin application

Postby Ruth » Wed May 15, 2024 6:55 am

Dear friends,

thank you once again for your kind help and directions.
Through reading the topics you suggested and then with the help of chatgpt :-) I managed to make it work. The image is now inline embedded as related attachement. Working perfectly. Thank you again.

And also thank you for pointing me to PowerShell - this sound like a lot to learn, but really interesting.

Kind regards to all of you and a very happy birthday to mod_harbour :-)
Ruth

Code: Select all  Expand view  RUN

// C:\FWH\SAMPLES\RUTHMAIL.PRG

#include "FiveWin.ch"
#Include "Outlook.ch"
#Include "Mail.ch"


MEMVAR smtpserver, serverport, sendusing, authenticate, usessl, username, ;
       password, timeout

MEMVAR cFrom, cTo, cSubject, cTextBody, cImgBase64, cImgPath, cBase64

FUNCTION Main()

   PRIV smtpserver, serverport, sendusing, authenticate, usessl, username, ;
        password, timeout

   PRIV cFrom, cTo, cSubject, cTextBody, cImgBase64

   smtpserver   := ""
   serverport   := 587
   sendusing    :=   2
   authenticate := .T.
   usessl       := .F. // .T. or .F.
   username     := "" //<your_email>
   password     := ""           // <sua_senha>
   timeout      := 60

   cFrom        := ""
   cTo          := ""
   cSubject     := "RUTH an RUTH"
  // cTextBody    := "RUTH: Teste de Email-Only TEST"
 
 
  cImgPath := "c:\fwh\samples\img\start_slide1.jpg"
  cImgBase64   := hb_base64encode(MEMOREAD("c:\fwh\samples\img\start_slide1.jpg"))
 


   SendMailCDO()

RETURN NIL

FUNCTION SendMailCDO()
 
   LOCAL objMsg, cHtml, oError, loBP
   LOCAL msgConf, lRet := .F.
 
   /*
   ? smtpserver, serverport, sendusing, authenticate, usessl, username, ;
     password, timeout
   */


   //' Server Configuration
   TRY

      msgConf := CreateObject("CDO.Configuration")

      WITH OBJECT msgConf:Fields

      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver"       ):Value := smtpserver
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport"   ):Value := serverport
      :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing"        ):Value := sendusing
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := authenticate
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl"       ):Value := usessl
      :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername"     ):Value := username
      :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword"     ):Value := password
      :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := timeout
 
      :Update()
 
      END WITH

 
   CATCH oError

      MsgInfo("Configuration instance object error " + ";"  + CRLF+ ;
              "Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
              "SubC: "  + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
              "OSCode: "+ TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
              "SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
              "Message: " + oError:Description )
 
   END
 
   //' Email
 
   TRY

      objMsg  := CreateObject("CDO.Message")

      WITH OBJECT objMsg

      :Configuration := msgConf
      :From          := cFrom
      :To            := cTo
      :Subject       := cSubject
     // :TextBody      := cTextBody
      :HTMLBody := "<h1>Hello!</h1><p>This is a test email with an inline image.</p>" + ;
                         "<p><img src='cid:id_image'></p><p>Best Regards!</p>"

     // :HTMLBody      := '<h1>HTML Content Here</h1><p>This is a TEST MAIL sent from FiveWin using CDO.</p>';
      //               +  '<img src="" >';
                    // +  '<img src="data:image/jpeg;base64,' + cImgBase64 + '" > ';
        //             + '<p><b>Test Ende</b></p>' // HTML formatted content
      loBP := :AddRelatedBodyPart(cImgPath, "id_image", 1)
            WITH OBJECT loBP:Fields
                :Item("urn:schemas:mailheader:Content-ID") := "id_image"
                :Update()
            END WITH

      :MDNRequested  := .F. // Indicates whether a Message Disposition Notification is requested on a message.
      :Send()

      END WITH
 
      // objMsg:Send()
      lRet := .T.

   CATCH oError

      MsgInfo("Could not send message" + ";"  + CRLF+ ;
              "Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
              "SubC: "  + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
              "OSCode: "+ TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
              "SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
              "Message: " + oError:Description )

      RETURN NIL

   END

   IF lRet // := .T.

      ? "PERFECT RUTH"
     

   ENDIF
 
RETURN NIL

// FIN / END - kapiabafwh@gmail.com
 
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: Send Emails from Fivewin application

Postby Enrico Maria Giordano » Wed May 15, 2024 7:38 am

paquitohm wrote:From ChatGPT, simple sample:

Code: Select all  Expand view  RUN
$SMTP.EnableSsl = $true


Thank you, but this is for SSL, not for TLS, if I'm not wrong.
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 8:24 am

TLS is simply a newer, more secure version of SSL. To use TLS instead of SSL, the servers usually use the port, which can be 587 or 993 or some other
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 9:12 am

Ok, thank you. In the meanwhile, I'm convinced myself (after reading some web pages) that CDO doesn't support TLS. :-(
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 FiveWiDi » Wed May 15, 2024 1:06 pm

Hello,

Although it is not exactly the discussion that is being discussed, it does have to do with sending emails on Fivewin.

I must send an email indicating "Delivery Acknowledgment", I use CDO and I can't find (AI either) how to do it using CDOSYS.

They have told me that it is done with the value "Generate-Delivery-Report" ( https://datatracker.ietf.org/doc/rfc4021/ ) but I can't get it to work.

Would you know how to do it?

Note: do not confuse "Acknowledgment of receipt/reading" with "Acknowledgment of DELIVERY". The first is sent by the recipient as a response, the second is done automatically by the recipient server.

Sorry for using this thread but I've been dealing with this issue for 3 months and I can't get anyone to clarify it for me, and since I've seen that they use CDOSYS here...

Thank you so much,

*****************************************************
Hola,

Aunque no es exactamente la discusión que se está tratando, sí que tiene que ver con el envío de mails en Fivewin.

Debo enviar un mail indicando "Acuse de ENTREGA", yo uso CDO y no encuentro (AI tampoco) como haceerlo usando CDOSYS.

Me han indicado que se hace con el valor "Generate-Delivery-Report" ( https://datatracker.ietf.org/doc/rfc4021/ ) pero no consigo que funcione.

Ustedes sabrían cómo hacerlo?

Nota: no confundan "Acuse de recepción/lectura" con "Acuse de ENTREGA". El primero lo envía el destinatario como respuesta, el segundo lo hace el servidor destinatario de manera automática.

Perdonen que use este hilo pero llevo 3 meses lidiando con este asunto y no consigo que nadie me lo aclare, y como he visto que aquí usan CDOSYS...

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

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 53 guests