Envio de Correos

294 views
Skip to first unread message

Hugo

unread,
Jul 29, 2025, 10:05:12 AM7/29/25
to Comunidad de Visual Foxpro en Español
Buenos días, un cliente decidió mudar sus correos a OFFICE365 y al querer enviar correos desde mi aplicación, no lo logro realizar como lo hacia antes, con CDO.
Me pasaron estos datos de configuración que lo extrajeron de OFFICE:

Puerto IMAP: 993
Puerto POP: 995
Puerto SMTP: 587
Casilla de Correo: ca...@aoita.org.ar
Contraseña: ********

Saludos.

Hugo

Victor Espina

unread,
Jul 29, 2025, 11:32:14 AM7/29/25
to Comunidad de Visual Foxpro en Español
yo tuve ese problema. CDO no te va a servir.  En mi caso tuve que usar una herramienta externa llamada MailSend:
https://github.com/muquit/mailsend/

Es basicamente una utilidad de linea de commando que puedes invocar para enviar emails, y funciona con Office365.   Te dejo el codigo que yo uso para invocarlo, para que te sirva de referencia:

* MAILSEND UTILITY
* https://github.com/muquit/mailsend/
*
LPARAMETERS poMsg,poXML, tnPriority, tlHTMLFormat


* VERIFICAMOS SI LA UTILIDAD MAILSEND.EXE ESTA
* DISPONIBLE EN EL PATH
*
LOCAL cMailSend
cMailSend = FULLPATH("mailsend.exe")


* SI EL ARCHIVO MAILSEND.EXE NO ESTA DISPONIBLE, INTENTAMOS
* DESCARGARLO DESDE LA NUBE
*
IF !FILE(cMailSend)
LOCAL cBuff
Kernel.MSG.Wait("Descargando componentes necesarios, por favor espere...")
cBuff = THIS._iget("http:\\www.tercermedio.com\store\mailsend.ex_", .F.)
Kernel.MSG.Wait()
IF LEN(cBuff) / 1024 < 1024
    RELEASE cBuff
RETURN "No se encontro la utilidad MAILSEND.EXE y no pudo descargarse automaticamente."
ENDIF
STRTOFILE(cBuff,"MAILSEND.EXE")
RELEASE cBuff
ENDIF



*-- Se toman los datos necesarios del archivo W3.XML
*
LOCAL cSMTPServer,nSMTPPort,cSenderName,cSenderAddress,cUserName,cUserPwd,lUseSSL,lUseTLS,lUseAuth
STORE "" TO cSMTPServer,cSenderName,cSenderAddress,cUserName,cUserPwd
STORE 0 TO nSTMPPort
STORE .F. TO lUSeSSL,lUseTLS,lUseAuth

WITH poXML.XML._Document._SendMail._SMTPServer
cSMTPServer = ._HostName.Data
nSMTPPort = ._Port.ToNum()
    cUserName = ._User.Data
    cUserPwd = ._Pwd.Data
ENDWITH
WITH poXML.XML._Document._SendMail._Sender
cSenderName = ._FullName.Data
cSenderAddress = ._Address.Data
ENDWITH
IF TYPE("poXml.xml._document._sendmail._smtpserver._useTLS.Data")="C"
  lUseTLS = (ALLT(UPPER(poXml.xml._document._sendmail._smtpserver._useTLS.Data)) $ "TRUE,YES")
ENDIF
IF TYPE("poXml.xml._document._sendmail._smtpserver._useSSL.Data")="C"
  lUseSSL = (ALLT(UPPER(poXml.xml._document._sendmail._smtpserver._useSSL.Data)) $ "TRUE,YES")
ENDIF
lUseAuth = (!EMPTY(cUserName))

IF THIS.debugMode
MESSAGEBOX("cSMTPServer: " + cSMTPServer + CHR(13)+CHR(10)+;
           "nSMTPPort: " + TRANS(nSMTPPort,"") + CHR(13)+CHR(10)+;
           "cUserName: " + cUserName + CHR(13)+CHR(10)+;
           "cUserPwd: " + cUserPwd + CHR(13)+CHR(10)+;
           "cSenderName: " + cSenderName + CHR(13)+CHR(10)+;
           "cSenderAddress: " + cSenderAddress + CHR(13)+CHR(10)+;
           "lUseSSL: " + TRANS(lUseSSL,"") + CHR(13)+CHR(10)+;
           "lUseTLS: " + TRANS(lUseTLS,"") + CHR(13)+CHR(10))
ENDIF


* CREAMOS LOS ARCHIVOS TEMPORALES A UTILIZAR
*
LOCAL cBATFile,cLOGFile,cMSGFile,cBodyMIMEType
cBATFile = Kernel.Utils.genTempFile("MS","BAT")
cLOGFile = FORCEEXT(cBATFile,"LOG")
cMSGFile = FORCEEXT(cBATFile,"TXT")
STRTOFILE(poMsg.Body,cMSGFile)

cBodyMIMEType = "text/plain"
IF ATC("<html",poMsg.Body) > 0
cBodyMIMEType = "text/html"
ENDIF



* PREPARAMOS EL COMANDO A EJECUTAR
*
LOCAL cCmd
cCmd = FULLPATH("mailsend.exe") + ;
       [ -ct 30]+;
       [ -log "] + cLogFile + ["] + ;
       [ -smtp "] + cSMTPServer + ["] + ;
       [ -port ] + ALLT(STR(nSMTPPort)) + ;
       [ -f ] + cSenderAddress

IF lUseAuth
cCmd = cCmd + ;
      [ -auth] + ;
      [ -user "] + cUserName + ["]+;
      [ -pass "] + cUserPwd + ["]
ENDIF

IF lUseSSL
cCmd = cCmd + [ -ssl]
ENDIF

IF lUseTLS
cCmd = cCmd + [ -starttls -ehlo]
ENDIF

cCmd = cCmd + ;
       [ -to "] + CHRT(poMsg.To,";",",") + ["] + ;
       [ -sub "] + poMsg.Subject + ["]
 
IF !EMPTY(poMSg.CC)
cCmd = cCmd + ;
       [ -cc "] + CHRT(poMsg.CC,";",",") + ["]
ENDIF

IF !EMPTY(poMsg.BCC)
cCmd = cCmd + ;
       [ -bc "] + CHRT(poMsg.BCC,";",",") + ["]
ENDIF

IF !EMPTY(poMsg.ReplyTo)
cCmd = cCmd + ;
       [ -rt "] + CHRT(poMsg.ReplyTo,";",",") + ["]
ENDIF

cCmd = cCmd + [ -attach "] + cMSGFile + [","] + cBodyMIMEType + [",i]

LOCAL i,cFile
FOR i = 1 TO poMsg.Attachments.Count
  cFile = FULLPATH(poMsg.Attachments.Items(i))
  IF FILE(cFile)
  cCmd = cCmd + [ -attach "] + cFile + ["]
  ENDIF
ENDFOR

STRTOFILE(cCmd, cBATFILe)


* EJECUTAMOS EL COMANDO Y LEEMOS EL ARCHIVO LOG RESULTANTE
LOCAL oWSH
oWSH = CREATEOBJECT("WScript.Shell")
oWSH.Run(cBATFile,2,.T.)

LOCAL tcReturn,cResult
cResult = ""
IF FILE(cLOGFIle)
cResult = FILETOSTR(cLOGFile)
ENDIF
DO CASE
   CASE EMPTY(cResult)
        tcReturn = "Error inesperado. Por favor, intente de nuevo"

   CASE ATC("sent ", cResult) > 0
    tcReturn = "SENT"

   CASE ATC("AUTH LOGIN", cResult) > 0
    IF TYPE("nMSRetries")="U"
    PRIVATE nMSRetries
    nMSRetries = 1
    tcReturn = THIS.sendmailWithMS(poMsg,poXML, tnPriority, tlHTMLFormat)
    ELSE
    tcReturn = cResult
    ENDIF

   OTHERWISE
        tcReturn = cResult
ENDCASE

IF NOT THIS.debugMode
ERASE (cLOGFile)
ERASE (cMSGFile)
ERASE (cBATFile)
ENDIF

RETURN tcReturn


Victor Espina

Hugo

unread,
Jul 29, 2025, 11:51:01 AM7/29/25
to Comunidad de Visual Foxpro en Español
Gracias Victor, voy a probar.

Saludos

Sergio Rojas

unread,
Jul 29, 2025, 12:49:05 PM7/29/25
to publice...@googlegroups.com

Hace algunos años me pasé a: CsFoxySmtp

https://foxydb.wordpress.com/csfoxysmtp/

--
Blog de la Comunidad Visual FoxPro en Español http://comunidadvfp.blogspot.com
---
Has recibido este mensaje porque estás suscrito al grupo "Comunidad de Visual Foxpro en Español" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a publicesvfoxp...@googlegroups.com.
Para ver este debate, visita https://groups.google.com/d/msgid/publicesvfoxpro/051bb1a2-1d87-4c7f-849c-af45dfc1541en%40googlegroups.com.

Hugo

unread,
Jul 30, 2025, 5:25:39 PM7/30/25
to Comunidad de Visual Foxpro en Español
intento usar foxysmtp y me devuelve el error y no logro saber que puede ser:

Screenshot_1.jpg

Antonio Meza

unread,
Jul 30, 2025, 6:09:42 PM7/30/25
to Comunidad de Visual Foxpro en Español
Que versión de la libreria estas usando la 1.0.7 ?

Usas VFP 9 o VFPA ?

Nota: verifica que la cuenta de correo tenga permitido enviar correos por el puerto SMTP

saludos

Zarlu

unread,
Jul 30, 2025, 6:57:45 PM7/30/25
to Comunidad de Visual Foxpro en Español
Buenas tardes!

La cuenta de correo "...@aoita.org.ar" corresponde al servidor de "smtp.office365.com"?

Mi escaso conocimiento lo ve raro

Suerte 
zarlu
Chetumal, Quintana Roo, México

Hugo

unread,
Jul 31, 2025, 7:39:48 AM7/31/25
to Comunidad de Visual Foxpro en Español

probe el smtp que me habia dado, mail.aoita.org.ar y me dio otro tipo de error, googleando, veo que para poder enviar correos desde Office 365, usan este smtp.

Saludos

Zarlu

unread,
Jul 31, 2025, 10:04:19 AM7/31/25
to Comunidad de Visual Foxpro en Español
Buenos días Hugo!

Cada proveedor de correo va de la mano con su propio servidor.
Si envías con cuentas de office365 entonces se puede usar su servidor.
Debes usar el servidor que te proporciona  "...@aoita.org.ar" y entonces resolver los errores que resulten

Una opción más para que pruebes: https://www.tbare.com/software/swithmail/

Suerte
zarlu
Chetumal, Quintana Roo, México


Jaime Ardila

unread,
Aug 8, 2025, 7:02:13 PM8/8/25
to publice...@googlegroups.com
Buenas tardes
He tenido problemas para enviar correo  de una una cuenta office365
Sale error 1429 no se  pudo enviar el mensaje al servidor smtp
El código de error de transporte  fue 0x80040217
Si alguien puede ayudar
Gracias 

--
Blog de la Comunidad Visual FoxPro en Español http://comunidadvfp.blogspot.com
---
Has recibido este mensaje porque estás suscrito al grupo "Comunidad de Visual Foxpro en Español" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a publicesvfoxp...@googlegroups.com.

Hugo

unread,
Aug 11, 2025, 7:34:17 AM8/11/25
to Comunidad de Visual Foxpro en Español
Por el tiempo que apremiaba, se decidio contratar a sendgrid como proveedor de SMTP.

Sin inconvenientes hasta el momento.

Saludos

PabloZa

unread,
Aug 11, 2025, 4:42:15 PM8/11/25
to Comunidad de Visual Foxpro en Español
Hola Hugo, yo hace un par de años que utilizo "SwithMail", y hasta ahora (toco madera) funciona todo ok.
Reply all
Reply to author
Forward
0 new messages