FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Envio de Email con WEBHOSTING
Posts: 58
Joined: Thu Aug 14, 2008 09:35 PM
Envio de Email con WEBHOSTING
Posted: Tue Jul 27, 2010 12:23 AM

Estimados Colegas

He tratado de enviar emails desde mi programa probando de muchas formas y todavia no tengo resultados. Prove con CDOSYS y para gmail funciona bien pero lo que es vital que se pueda manejar con hosting empresariales, el smtp en mi caso es "mail.easycomp.cl" y ocupo el correo contacto@easycomp.cl con el puerto 25, pero sale el tipico error ya nombrado varias veces.

¿ Alguien tiene un ejemplo funcionando con un hosting empresarial ? Les agradesco mucho su ayuda porque es Urgente!!!!!

Waldemar González

Bendiciones

¡ Dios es nuestra fortaleza !
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Envio de Email con WEBHOSTING
Posted: Tue Jul 27, 2010 06:09 AM
This sample is working fine for me. I have used my SMTP server hosted with a web hosting company to send the mail to my gmail id.

Code (fw): Select all Collapse
#Include "FiveWin.ch"

Function Main()
    Local oEmailCfg,oEmailMsg

    TRY
       oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
      WITH OBJECT  oEmailCfg:Fields
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value :=   "mail.xxxxxxxx.com"
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value :=  25
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2   // Remote SMTP = 2, local = 1
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value :=   .T.
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value :=  .F.
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value :=  "xxanser@xxxxxxxx.com"
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value :=  "xxxxxx"
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
         :Update()
      END WITH
    CATCH oError
      MsgInfo( "Could not create message configuration" + ";"  + ;
             "Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
             "SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
             "OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
             "SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
             "Message: " + oError:Description )
       Return .F.
    END
    oError:=NIL


    TRY
     oEmailMsg := CREATEOBJECT ( "CDO.Message" )
     WITH OBJECT oEmailMsg
        :Configuration =  oEmailCfg
        :From = chr(34)+" Anser K.K. "+chr(34)+ "<anser@xxxxxxxx.com>" // This will be displayed in the From (The email id does not appear)
        :To = "xxanserkk@xxxxx.com"    // <-----   Place the TO email address
        :Subject =  "This is a Tst message"
        :ReplyTo =  "xxanser@xxxxxxxxx.com" 
        :Sender =  "xxanser@xxxxxxxxx.com"  // Read Receipt message is send to this
        :Organization =  "My xxxxxx Company"    // "My Company Name"
        :HTMLBody =  "<HTML> Hello  </HTML>"
        :Send()
     END WITH
     SysRefresh()
    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 .F.
    
    END
    MsgInfo("Email Send")

Return





Regards
Anser
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Envio de Email con WEBHOSTING
Posted: Tue Jul 27, 2010 06:53 AM
Waldemar,

wyerco wrote:
He tratado de enviar emails desde mi programa probando de muchas formas y todavia no tengo resultados. Prove con CDOSYS y para gmail funciona bien pero lo que es vital que se pueda manejar con hosting empresariales, el smtp en mi caso es "mail.easycomp.cl" y ocupo el correo contacto@easycomp.cl con el puerto 25, pero sale el tipico error ya nombrado varias veces.

Es cierto, el problema que tenemos al usar CDO es que no tenemos un buen control de errores, y si algo está mal no podemos saber a ciencia cierta que es.
Aún así, CDO bien configurado no tiene problemas para enviar correos. Los hostings empresariales no tienen ninguna particularidad, asegúrate cuales son las condiciones del servicio. El protocolo smtp es muy estandar, lo que suele cambiar son la forma de autenticarse. Eventualmente los antivirus están bloqueando el puerto 25 a las aplicaciones, habría que asegurarse que ese no es tu caso.
Es más fácil ayudarte si pones el trozo de código donde pones los parámetros para saber que puede estar mal. Revisa los parámetros de configuración.
Prueba de usar esos parametros con tu cliente de correo y verifica que funcionan los parámetros que estas usando. Si funciona, copia la imagen de la configuracion de tu cliente de correos y el código para ver si el problema son los parámetros.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Posts: 58
Joined: Thu Aug 14, 2008 09:35 PM
Re: Envio de Email con WEBHOSTING
Posted: Wed Jul 28, 2010 12:06 AM

Anser

Thanks for your help, in fact your example it works exelent and thanks all people that gave me a hand too.

Thank you very much.

Best regards

Waldemar González

God Bless you :D :lol:

¡ Dios es nuestra fortaleza !
Posts: 131
Joined: Tue Dec 26, 2006 04:50 PM
Re: Envio de Email con WEBHOSTING
Posted: Mon Apr 23, 2012 09:29 PM

Hello everyone, I just tried this code and it works when there are not attachments, but if I add the line:

:AddAttachment := AllTrim( cArchp )

Then I get the following error:

Could not send message;
Error: 13;
SubC: 1004;
OSCode: 0;
SubSystem: BASE;
Message: Class: 'NIL' has no exported method

Any suggestion?

Thanks in advance.

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Envio de Email con WEBHOSTING
Posted: Tue Apr 24, 2012 06:35 AM
:AddAttachment := AllTrim( cArchp )


1. Please check the value/data in the variable named cArchp. Hope that it is not empty
2. cArchp should contain the full path of the file that you are trying to attach For Eg:"D:\Test\List.Doc"
3. The file that you are trying to attach should exist in the path that you have specified.

Code (fw): Select all Collapse
If !Empty(cArchp)
   :AddAttachment := AllTrim( cArchp )
Endif


Regards

Anser
Posts: 731
Joined: Fri Oct 07, 2005 07:42 AM
Re: Envio de Email con WEBHOSTING
Posted: Tue Apr 24, 2012 02:14 PM

Put path complete;

Fail;
.\file.txt

Ok;
c:\temp\file.txt

Regards

Saludos

Rafa Carmona ( rafa.thefullARROBAgmail.com___quitalineas__)
Posts: 131
Joined: Tue Dec 26, 2006 04:50 PM
Re: Envio de Email con WEBHOSTING
Posted: Thu Apr 26, 2012 05:18 PM

Thanks guys for your response, I added a little stop showing the value of the variable "cArchp", it shows the full path to the file I want to send. I must have started by telling you I am using a old versión of Fivewin (2.6), it might be the problem, if it is not and you guys have anothe suggestion it will be welcomed.

Thanks

Continue the discussion