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,
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.
paquitohm wrote:sorry, I meant TLS
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?
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
paquitohm wrote:In my case I send from an outlook account on port 587 using TLS
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?
# 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.com
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 73 guests