Page 1 of 4

enviar correo electronico / send eMail

Posted: Fri Jun 28, 2013 9:00 pm
by CarlosRD
hola a todos:

tengo este codigo que copie de un post de gregory filatov, pero no me funciona. alguien me puede decir por que?
se compila sin problema y aparentemente funciona bien, pero me dice "Correo NO enviado"

hi all:

i have this gregory filatov's code, but it does not work to me. can someone help me?
it works apparently with out problem but the final result is "UNSENT MAIL"

saludos / regards.

Code: Select all

#include "hmg.ch"

Function Main()

set century on
set date ital

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 200 ;
      HEIGHT 200 ;
      MAIN;
      TITLE 'Button Test'


      @ 30,70 BUTTON Button_1 WIDTH 50 HEIGHT 50 ACTION ENVIARCORREO()

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return

   
FUNCTION ENVIARCORREO()   
   cSMTPServer   := "smtp.smartnext.com"
   cPopServer    := "mail.smartnext.com"
   cFrom         := "facturacion@zuca.com.mx"
   cTo           := "creydav@gmail.com"
   cSMTPPassWord := "micontrasena"

// hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, bTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, lTLS, cSMTPPass, cCharset, cEncoding )

   MsgInfo( iif(hb_SendMail( cSMTPServer,;
                  NIL,;
                  cFrom,;
                  cTo,;
                  NIL /* CC */,;
                  NIL /* BCC */,;
                  "test: body",;
                  "test: subject",;
                  NIL /* attachment */,;
                  cFrom,;
                  cSMTPPassword,;
                  cPopServer,;
                  NIL /* nPriority */,;
                  NIL /* lRead */,;
                  .F. /* lTrace */,;
                  .T. /* lPopAuth */,;
                  .F. /* lNoAuth */,;
                  NIL /* nTimeOut */,;
                  NIL /* cReplyTo */,;
                  .F. /* lTLS */,;
                  cSMTPPassWord ), "Correo enviado satistactoriamente", "Correo NO enviado"), "Resultado" )
				  
RETURN

Re: enviar correo electronico / send eMail

Posted: Fri Jun 28, 2013 10:10 pm
by jucar_es
Buenas tardes

adjunto mi ejemplo para envio de emails

a mi me funciona

espero le sirva

Re: enviar correo electronico / send eMail

Posted: Fri Jun 28, 2013 10:27 pm
by danielmaximiliano
Hola Carlos :
Si es cliente de http://www.smartnext.com/soporte/ , consulte ahi si en servidor SMTP necesita autentificación
o si tambien nesecita tanspoerte seguro SSL

Code: Select all

.T. /* lPopAuth */,;
.F. /* lTLS */,;
va a tener que jugar con estos dos parametros para el envio de email.


aqui tiene una ayuda para en envio de email mediante Harbour : http://hmgforum.com/viewtopic.php?f=9&t=2559

aqui CDOSYS : http://hmgforum.com/viewtopic.php?f=24&t=2361

para transporte seguro necesita instalar OpenSSL.
tiene las 2 versiones
1) x86 y x64
2) Desarrollo y Light
recomiendo instalar Light. http://slproweb.com/products/Win32OpenSSL.html

Re: enviar correo electronico / send eMail

Posted: Mon Jul 01, 2013 3:12 pm
by CarlosRD
thanks jucar, daniel

i need by request in my job, to create emails in OUTLOOK, anybody know where can i get OLE info (instructions)?

*************

gracias jucar, daniel

necesito por requerimientos en mi trabajo, crear emails en OUTLOOK, alguien sabe en donde puedo conseguir informacion de OLE-OUTLOOK???

gracias, saludos / thanks, regards

Re: enviar correo electronico / send eMail

Posted: Mon Jul 01, 2013 3:28 pm
by Rathinagiri
This is from Harbour contrib folder hbwin

Code: Select all

STATIC PROCEDURE Exm_MSOutlook2()

   LOCAL oOL, oLista, oMail
   LOCAL i

   IF ( oOL := win_oleCreateObject( "Outlook.Application" ) ) != NIL

      oMail := oOL:CreateItem( 0 /* olMailItem */ )

      FOR i := 1 TO 10
         oMail:Recipients:Add( "Contact" + hb_ntos( i ) + ;
            "<contact" + hb_ntos( i ) + "@server.com>" )
      NEXT

      oLista := oOL:CreateItem( 7 /* olDistributionListItem */ )
      oLista:DLName := "Test with distribution list"
      oLista:Display( .F. )
      oLista:AddMembers( oMail:Recipients )
      oLista:Save()
      oLista:Close( 0 )
   ELSE
      ? "Error. MS Outlook not available.", win_oleErrorText()
   ENDIF

   RETURN
This is from an example from a web site for powerbuilder. I think it can be converted to Harbour easily.

Code: Select all

Creating and Sending a New Mail Item
Create an OLEObject and connect to Outlook. Use the following code to send a mail item. The argument to the 'CreateItem' function specifies the type of item that is going to be created.
'0' Mail Item
'1' Appointment
'2' Contact
'3' Task

OLEObject ole_item, ole_attach
//Creates a new mail Item
ole_item = ole_outlook.CreateItem(0)
//Set the subject line of message
ole_item.Subject = "A new attachement for you"
//Body of mail message
ole_item.Body = "Here is a new attachment for you :"+Char(13)
//Recipient(s) Use a semicolon to separate multiple recipients
ole_item.To = "MaheshThatavarthi"
ole_attach = ole_item.Attachments
ole_attach.add(complete path of the file)
ole_item.Display //displays the message
ole_item.Send //sends the message

Re: enviar correo electronico / send eMail

Posted: Tue Jul 02, 2013 7:44 pm
by CarlosRD
Thanks Rathinagiri:

Taking your sample code, and with some modifications I got this simple sample to send emails with Outlook 2007. You can add recipients through a routine and also attachments.
With Outlook 2007, you need to open it using the "execute file" first of all, I think it's a bug that has the OL-2007.
Hope this helps HMG community. Greetings.

************************************

Gracias Rathinagiri:

Tomando como base su codigo, y con algunas modificaciones, he conseguido este ejemplo para enviar correos con Outlook 2007. Puede agregar destinatarios y archivos adjuntos por medio de una rutina.
Con Outlook 2007, es necesario primero abrirlo, creo que por un error del propio Outlook.
Espero que esto sirva a la comunidad HMG. Saludos.

Code: Select all

#include "hmg.ch"

Function Main()

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 400 ;
      HEIGHT 400 ;
      MAIN;
      TITLE 'Enviar correo con Outlook'


      @ 30,70 BUTTON Button_1 CAPTION "enviar" ACTION ENVIARCORREO()

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return

   
FUNCTION ENVIARCORREO()   

  execute file "\program files\microsoft office\office12\outlook.exe"
  oOutLook := CreateObject("Outlook.Application")

  oMail  := oOutLook:CreateItem(0)

  oRecip := oMail:Recipients
  oRecip:Add( "creydav@gmail.com" )
  oRecip:Add( "facturacion@zuca.com.mx" )

  oAdjunto:=oMail:Attachments
  oAdjunto:Add( "c:\saz\rc8001.pdf" )
  oAdjunto:Add( "c:\saz\rc8001.xml" )
  
  oMail:Subject := "Asunto"
  oMail:Body    := "Cuerpo de la prueba"
  oMail:Send()
           
RETURN

Re: enviar correo electronico / send eMail

Posted: Tue Jul 02, 2013 8:17 pm
by Rathinagiri
Wow! That is so great. Thanks a lot Carlos.

Re: enviar correo electronico / send eMail

Posted: Tue Sep 10, 2013 1:02 pm
by EduardoLuis
Hi Friends:

I'm developing a system for a friend who needs that some files must be sent attached with a mail.-
I use a routine that lets him insert any text as body message, but he needs to send attached several (up to 5) pdf document with the mail.- As he use only MSIMN with pop3 adreess i can't use latest version for outlook 2007.-
I've check for information about it, but i can't find anything to solve the problem.-
If someone could help me.-
With regards. Eduardo

Hola Amigos:

Estoy desarrollando un sistema para un amigo que necesita enviar archivos adjuntos con su mail.-
Yo utilicé una rutina que le permite ingresar largos textos en el cuerpo del mensaje, pero lo que el necesita es adjuntar (hasta 5) archivos pdf conjuntamente con el mail.- Como el utiliza unicamente MSIMN con casillas POP3, no pude utilizar la ultima versión para Outlook 2007.-
He chequeado por información sobre el tema, pero no encontré nada que me permitiera resolver el problema, Si alguien puede orientarme, lo agradezco.-
Cordialmente. Eduardo

Re: enviar correo electronico / send eMail

Posted: Tue Sep 10, 2013 1:08 pm
by danielmaximiliano
Hola Eduardo :

Hace tiempo se hicieron varios topicos sobre envio de Email.
hay rutinas basadas en Sendmail() otras sobre CDOsys de Microsoft pero todas ellas necesitan de la libreria OpenSSL.

aca tenes algo funcional que puede ser mejorada :http://hmgforum.com/viewtopic.php?f=9&t ... =incomming

Re: enviar correo electronico / send eMail

Posted: Tue Sep 10, 2013 5:36 pm
by EduardoLuis
Hi Dany:

I've test some time ago your suggestion, but it don't solve my problem.-
Thanks again.-
Eduardo

Hola Dany:

Hace tiempo testeé ese ejemplo, pero con él no pude resolver el problema.-
Gracias de todos modos.-
Eduardo