xHarbour Builder + FivewinH with Outlook Office 2003

xHarbour Builder + FivewinH with Outlook Office 2003

Postby George » Mon Sep 04, 2006 2:11 pm

Hello forum,

The following code work *BUT*

Code: Select all  Expand view
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  Expand view
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
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Postby James Bott » 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).
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xHarbour Builder + FivewinH with Outlook Office 2003

Postby NK » Tue Sep 05, 2006 1:18 pm

George wrote:Hello forum,

The following code work *BUT*

Code: Select all  Expand view
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  Expand view
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  Expand view
TRY
  ... sendroutine
CATCH
  MsgAlert("No Mail send")
END

??

Best regards, Norbert
User avatar
NK
 
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany

Postby George » 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
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Postby James Bott » Wed Sep 06, 2006 2: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby George » Wed Sep 06, 2006 3: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
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Postby James Bott » Wed Sep 06, 2006 7: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby George » 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
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests