Page 1 of 1

xHarbour Builder + FivewinH with Outlook Office 2003

Posted: Mon Sep 04, 2006 2:11 pm
by George
Hello forum,

The following code work *BUT*

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")


BUT if I did cancel, before to send the email, the following message show:

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)

BUT if I try to destroy all the created OLE objects, also get ERRORS

Some ideas programmers fellows and friends?

I am using FWH 2.7 Aug_06, xHarbour Builder RC9 Aug_06 and Ms-Office 2003

Beside, I would like to know if your are using or used in the past, BLAT.DLL, (or BLAT.EXE command line) to send emails, and how is your experience with it.

Regards


George

Posted: Mon Sep 04, 2006 11:01 pm
by James Bott
MAPI Mail Sample:

define mail oMail ;
to ::oCustomer:email;
subject "Invoice "+::invno;
from user;
files (cFile),cFile

activate mail oMail

Note that cFile MUST contain the path.

Clauses

FILES - the first parameter must contain the full name of the file including the path. The second parameter must contain the name you want to apprear as the attachment name. Doing (cFile),cFile makes the attachment appear with the filename (without path).

Re: xHarbour Builder + FivewinH with Outlook Office 2003

Posted: Tue Sep 05, 2006 1:18 pm
by NK
George wrote:Hello forum,

The following code work *BUT*

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")


BUT if I did cancel, before to send the email, the following message show:

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)

BUT if I try to destroy all the created OLE objects, also get ERRORS

Some ideas programmers fellows and friends?

I am using FWH 2.7 Aug_06, xHarbour Builder RC9 Aug_06 and Ms-Office 2003

Beside, I would like to know if your are using or used in the past, BLAT.DLL, (or BLAT.EXE command line) to send emails, and how is your experience with it.

Regards


George
have you testet

Code: Select all

TRY
  ... sendroutine
CATCH
  MsgAlert("No Mail send")
END
??

Best regards, Norbert

Posted: Wed Sep 06, 2006 12:54 am
by George
James and NK

Thanks for your help.

Now I get the following alert dialog message:

Can't contact LDAP directory server (81)

Nothing is working for me to send eMails :x

Regards


George

Posted: Wed Sep 06, 2006 2:30 am
by James Bott
George,

If you use the FROM USER clause does the Outlook new message dialog come up? If not perhaps Outlook is not set as the default MAPI client.

James

Posted: Wed Sep 06, 2006 3:59 pm
by George
James,

The OUTLOOK dialog came up OK with attachment included. But I receive the message

Can't contact LDAP directory server (81);

Pressing the SEND button do nothing, but the email is in outlook INBOX folder. I have to go to OUTLOOK and do the send/receive menu option in order to send the email. I would like that after press SEND button, from outlook dialog, the email gone inmediately.


Regards


George

Posted: Wed Sep 06, 2006 7:16 pm
by James Bott
George,

>The OUTLOOK dialog came up OK with attachment included. But I receive the message

>Can't contact LDAP directory server (81);

OK, a Google search shows that the above message has nothing to do with Fivewin, but is an Outlook bug that can be fixed. See here:

"Can't Contact LDAP Directory server (81)" error message when you write an e-mail message in Outlook 2002
http://support.microsoft.com/kb/323612/

>Pressing the SEND button do nothing, but the email is in outlook INBOX folder.

I presume you meant the OUTBOX not the INBOX.

>I have to go to OUTLOOK and do the send/receive menu option in order to send the email. I would like that after press SEND button, from outlook dialog, the email gone inmediately.

This could be one of two things. Either Outlook is not configured to send all emails immediately, or the email is not being sent because the address is not being resolved per the bug causing the error message. Once you fix the Outlook bug, then maybe this will be solved too.

If you have another computer around you might try tesing the Fivewin MAPI email code on it too.

James

Posted: Wed Sep 06, 2006 11:12 pm
by George
James,

"Can't Contact LDAP Directory server (81)" error message when you write an e-mail message in Outlook 2002
http://support.microsoft.com/kb/323612/

This problem is resolved. Thank you.

>I presume you meant the OUTBOX not the INBOX.
You are right is OUTBOX


>I have to go to OUTLOOK and do the send/receive menu option in order >to send the email. I would like that after press SEND button, from >outlook dialog, the email gone inmediately.

Nothing is sent until I enter to Outlook. I tried everything I believe but does not work

Regards


George

Posted: Wed Sep 06, 2006 11:25 pm
by James Bott
George,

>I have to go to OUTLOOK and do the send/receive menu option in order >to send the email. I would like that after press SEND button, from >outlook dialog, the email gone inmediately.

>Nothing is sent until I enter to Outlook. I tried everything I believe but does not work.

OK, but is Oulook configured to send emails immediately? I don't have a copy of Oulook on this PC, but with Outlook Express go to Tools, Options, select the Send tab and check "Send messages immediately." If that is not checked then you have to manually select the Send button as you are having to do.

James