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.
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.
Enrico Maria Giordano wrote:CDO does not allow sending from accounts with the SSL protocol,This is not true. I'm using CDO with SSL without problems.
paquitohm wrote:sorry, I meant TLSIt 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?
What is the working solution to send emails with FWH? that works with or without Outlook installed and accepts attachments and any protocols?
thanks
Enrico Maria Giordano wrote: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: powershellsorry, I meant TLSIt 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?
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?There are more than one posibilities. Personally, I'm still using CDO.
thanks
paquitohm wrote:In my case I send from an outlook account on port 587 using TLSSounds interesting. Can you share a sample, please?
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
Enrico Maria Giordano wrote:In my case I send from an outlook account on port 587 using TLSSounds interesting. Can you share a sample, please?
# 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)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// 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.compaquitohm wrote:From ChatGPT, simple sample:Thank you, but this is for SSL, not for TLS, if I'm not wrong.
$SMTP.EnableSsl = $true
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
Un Saludo
Carlos G.
FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home