FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xHarbour Builder + FivewinH with Outlook Office 2003
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Mon Sep 04, 2006 02:11 PM
Hello forum,

The following code work *BUT*

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:

 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Mon Sep 04, 2006 11:01 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 97
Joined: Sun Nov 20, 2005 04:32 PM
Re: xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Tue Sep 05, 2006 01:18 PM
George wrote:Hello forum,

The following code work *BUT*

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:

 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
TRY
  ... sendroutine
CATCH
  MsgAlert("No Mail send")
END

??

Best regards, Norbert
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Wed Sep 06, 2006 12:54 AM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Wed Sep 06, 2006 02:30 AM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Wed Sep 06, 2006 03:59 PM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Wed Sep 06, 2006 07:16 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Wed Sep 06, 2006 11:12 PM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
xHarbour Builder + FivewinH with Outlook Office 2003
Posted: Wed Sep 06, 2006 11:25 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion