Page 1 of 1

xHarbour Builder + FivewinH Con Outlook Office 2003

Posted: Mon Sep 04, 2006 2:02 pm
by George
Hola foro,

El siguiente codigo trabaja *PERO*

Code: Select all

FUNCTION SendEmailByOutLook (cReportName)            //Using Ole
	LOCAL oOutLook,;
	oMailItem,;
	oRecip,;
	oAttach


/* creating the OLE object */
	oOutLook := TOleAuto():New("Outlook.Application")

/* creating a Mail Item object*/
	oMailItem := oOutLook:Invoke("CreateItem", 0)

	// creating Recipients object and attaching addresses
	oRecip := oMailItem:Invoke("Recipients")
	oRecip:Invoke("Add", "my_email_address@msn.com")

   /* creating subject and body of the mail message using the
   SET method of the mail item object */
	oMailItem:Set("Subject", "Sending an e-mail with Outlook")
	oMailItem:Set("Body", "Email test using outlook"+CRLF+CRLF)

  /* creating an Attachment object and adding files to send */
	oAttach := oMailItem:Invoke("Attachments")

	oAttach:Invoke("Add", cReportName)

	//oMailItem:Display(.T.)

  /* Mail message created, now send the full featured message*/
  	oMailItem:Invoke("Send")

	/* Destroy all the created OLE objects
		oRecip:End()
	   oAttach:End()
		 oMailItem:End()
		oOutLook:End()
	*/

   /* done */
	MsgInfo("Email Message sent")


PERO si trato de cancelar antes de enviar el mensaje recibo el siguiente error:

Code: Select all

 Time from start: 0 hours 1 mins 31 secs 
   Error occurred at: 09/04/2006, 09:52:21
   Error description: Error Outlook.Application:CREATEITEM/16389  E_FAIL: RECIPIENTS
   Args:

Stack Calls
===========
   Called from: win32ole.prg => TOLEAUTO:RECIPIENTS(0)
   Called from:  => HB_EXECFROMARRAY(0)
   Called from: win32ole.prg => TOLEAUTO:INVOKE(415)
   Called from: rpreview0.prg => SENDEMAILBYOUTLOOK(2069)

PERO si uso los mensajes para cerrar los objetos creados por ole
tambien recibo mensaje de error.

Alguna idea compaƱeros por donde anda el problema.
Estoy usando FWH 2.7 Aug_06, xHarbour Builder RC9 Aug_06 y Ms-Office 2003

Por otro lado me gustaria aber si alguien ha usado BLAT.DLL para enviar email y cual ha sido su experiencia

Saludos


George[/code]