Buenos días Enrico. Con sólo un módulo, funcionará. El problema es cuando se trata de un sistema completo gigantesco. Haré lo siguiente: CREAR LAS PANTALLAS DE ENTRADAS Y GETS y las incorporaré al sistema para ver si se congela usando SENDMAIL también. Muchas gracias por tu ayuda.
******************************************************************************
* Enviando Emails e Anexos Usando SENDMAIL.PRG 18/05/2025 *
* *
* Agradecimentos Para: Enrico Maria Giordano: SENDMAIL.PRG *
* *
* Contato: +55(11) 9.5150-7341 *
* Modificado por: Joao Santos C:\SENDMAIL - Projeto. *
* Ultima Atualizacao: 18/05/2025 Por: Joao Santos Usando: MINGW GCC 15.1 *
******************************************************************************
#Include "Fivewin.ch"
FUNCTION Main()
LOCAL cFrom := "joao@pleno.com.br" // De
LOCAL cServer := "smtp.pleno.com.br" // Servidor
LOCAL cTo := "kapiabafwh@gmail.com; e.m.giordano@emagsoftware.it" // Para
LOCAL cSubject := "TESTE DE SENDMAIL VIA GCC" // Assunto
LOCAL cMessage := "Enrico Maria Giordano" // Mensagem
LOCAL aAttach := NIL // Anexos/adjuntos.
LOCAL cSender := "Joao Santos" // Remetente/Remitente
LOCAL cUser := "pleno@pleno.com.br" // usuario
LOCAL cPassword := "2424242" // Senha/contrase¤a
LOCAL aCC := NIL // NO FUNCIONAL // Com Copia
LOCAL lHtml := .F. // Html
LOCAL cPort := "587" // NIL // Porta
LOCAL lNotification := .F. // Notificacao(recebeu?)
LOCAL lSSL := .F.
? SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, ;
cUser, cPassword, aCc, lHtml, cPort, lNotification, lSSL )
RETURN NIL
#command IF <condition> THEN <*statements*> => if <condition> ; <statements> ; end
FUNCTION SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, ;
cUser, cPassword, aCc, lHtml, cPort, lNotification, lSSL )
LOCAL lOk := .F., oCfg, oMsg, cCc := "", i
DEFAULT lHtml := "<html" $ Lower( cMessage )
DEFAULT lNotification := .F.
DEFAULT lSSL := .F.
TRY
oCfg := CREATEOBJECT( "CDO.Configuration" )
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value = cServer
IF .NOT. EMPTY( cPort )
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value = VAL( cPort )
ENDIF
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value = 2
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = .F.
IF .NOT. EMPTY( cUser ) .AND. !EMPTY( cPassword )
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = .T.
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value = cUser
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value = cPassword
oCfg:Fields( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value = lSSL
ENDIF
oCfg:Fields:Update()
oMsg := CREATEOBJECT( "CDO.Message" )
oMsg:Configuration := oCfg
IF .NOT. EMPTY( cSender ) THEN cFrom = ["] + cSender + ["] + " <" + cFrom + ">"
oMsg:From := cFrom
oMsg:To := cTo
oMsg:Subject := cSubject
IF .NOT. EMPTY( aCc )
FOR i = 1 TO LEN( aCc )
IF i > 1 THEN cCc += ";"
cCc += aCc[ i ]
NEXT
oMsg:CC = cCc
ENDIF
IF .NOT. lHtml
oMsg:TextBody := cMessage
ELSE
oMsg:HTMLBody := cMessage
ENDIF
IF .NOT. EMPTY( aAttach )
FOR i = 1 TO LEN( aAttach )
oMsg:AddAttachment( aAttach[ i ] )
NEXT
ENDIF
IF lNotification
oMsg:Fields( "urn:schemas:mailheader:disposition-notification-to" ):Value = cFrom
oMsg:Fields:Update()
ENDIF
oMsg:Send()
lOk = .T.
CATCH
END
RETURN( lOk )
// FIN / END - ================= kapiabafwh@gmail.com =======================
Regards, saludos.