jueves, 2 de septiembre de 2021

Envío de correo

 

MySession is emailSMTPSession
MyMessage is Email
myAttach  is emailAttach
sFile     is string


MySession..ServerAddress = "smtp.gmail.com"
// The TLS port depends on the provider, don't forget to check it!
MySession..Option = emailOptionSecuredTLS
MySession..Port = 587 //587 o 465
MySession..Name = "xxxxxxxx@gmail.com"
MySession..Password = "yyyyyyyyyyy"
EmailSetTimeOut(10)
IF EmailStartSession(MySession) = False THEN
Error("no se pudo iniciar la sesión SMTP", ErrorInfo())
RETURN
END
EmailReset(MyMessage)
MyMessage..Sender = "xxxx@gmail.com"
MyMessage..SenderAddress = "xxxxx@gmail.com"
Add(MyMessage..Recipient, "zzzzzz@hotmail.com")
MyMessage..Subject = "Envío de su cita de verificación"
MyMessage..Message = "Descargue el documento adjunto"
//adjunto el archivo anexo
// Select the file to attach
//sFile = fSelect("", "", "Selecciona el documento a anexar...", ...
// "PDF documents (*.PDF)" + TAB + "*.PDF", "*.PDF")
// Build the EmailAttach variable if exist

// Generate a unique PDF file name
sArchivo is string = fWebDir() + "\" + "Cita_" + DateSys() + TimeSys() + ".pdf"  
// Configure the destination of the print
iDestination(iPDF, sArchivo)  
// Print the RPT_OrderPDF report
iInitReportQuery(RPT_Cita, gnFolio)
iPrintReport(RPT_Cita, gnFolio)
IF fFileExist(sArchivo) = True
myAttach..Name = fExtractPath(sArchivo, fFileName + fExtension)
myAttach..Content = fLoadBuffer(sArchivo)
myAttach..ContentType = "application/pdf"
myAttach..ContentDescription = "A PDF document"
// Add the attachment
Add(MyMessage..Attach, myAttach)
END
EmailSendMessage(MySession,MyMessage)
EmailCloseSession(MySession)
fDelete(sArchivo)

Try catch end

 // -------------------------------------------------- // Procedure principal que executa uma query com tratamento de exceção // -----------...