Code: Select all
#ifndef _CDOSYS_CH
#define _CDOSYS_CH
#define cdoSMTPServer "http://schemas.microsoft.com/cdo/configuration/smtpserver"
#define cdoSMTPServerPort "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
#define cdoSendUsing "http://schemas.microsoft.com/cdo/configuration/sendusing"
#define cdoSMTPPickupFolder "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
#define cdoSMTPAuthenticate "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
#define cdoSendUserName "http://schemas.microsoft.com/cdo/configuration/sendusername"
#define cdoSendPassword "http://schemas.microsoft.com/cdo/configuration/sendpassword"
#define cdoSMTPUseSSL "http://schemas.microsoft.com/cdo/configuration/smtpusessl"
#define cdoTimeOut "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
#define cdoBufferOnWrite "http://schemas.microsoft.com/cdo/configuration/flushbuffersonwrite"
#endif
METHOD SendMail() CLASS TMain
LOCAL oError := NIL
LOCAL oEmailCfg, oEmailMsg
LOCAL cDirBackup := "c:\backup\respaldo.rar"
IF IsInternet()
TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields
:Item( cdoSMTPServer ):Value := oApp:cSmtpServidor // "miempresa.com.mx"
:Item( cdoSMTPServerPort ):Value := val( oApp:cSmtpPuerto ) // "480"
:Item( cdoSendUsing ):Value := val( oApp:cSmtpTipoEnvio ) // "2"
:Item( cdoSMTPAuthenticate ):Value := iif( alltrim(oApp:cSmtpAutenticacion)$"S,s", .T., .F. ) // "S"
:Item( cdoSMTPUseSSL ):Value := iif( alltrim(oApp:cSmtpUsaSSL)$"S,s", .T., .F. )
:Item( cdoSendUserName ):Value := oApp:cSmtpUsuario // "master.mango@miempresa.com.mx"
:Item( cdoSendPassword ):Value := oApp:cSmtpPass // "DrTe$*D34alK,"
* :Item( cdoTimeOut ):Value := 30
* :Item( cdoBufferOnWrite ):Value := .T.
:Update()
END WITH
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration := oEmailCfg
:From := "Pruebas <pruebas@miempresa.com.mx>"
:To := "prueba.xx@gmail.com"
* :bcc := "pruebas.yy@gmail.com"
:Organization := "Mi Empresa"
:Subject := "Envio archivos comprimidos " + DTOC(Date()) + "»"
:TextBody := "Proceso de Envio informacion del Día : " + date() + CRLF + CRLF + ;
"Efectuada el : " + date() + " a las : " + Time() + CRLF + ;
"Algo mas que le quieras poner..."
:AddAttachment := cDirBackup
:Send()
END WITH
MsgInfo("La info se envio ...","Aviso")
CATCH oError
MsgInfo( "No se pudo transferir la info ..." + CRLF +;
"Error: " + CHR(9) + transform( oError:GenCode, NIL) + CRLF +;
"SubC: " + CHR(9) + transform( oError:SubCode, NIL) + CRLF +;
"OSCode: " + CHR(9) + transform( oError:OsCode, NIL) + CRLF +;
"SubSystem: " + CHR(9) + transform( oError:SubSystem, NIL) + CRLF +;
"Mensaje: " + CHR(9) + oError:Description, oApp:cEmpresa )
END
oEmailCfg := NIL
oEmailMsg := NIL
ELSE
? "No se detecto conexión a Internet !!",;
ENDIF
RETURN( SELF )