Interactive mail via Outlook

Interactive mail via Outlook

Postby Marco Turco » Mon Feb 20, 2006 2:17 pm

Hi,
is there a way to show the standard Outlook dialog to send an email via OLE ? I use this routine but the email start immediatly without the feature for the user to modify/integrate the email contents.

Thanks in advance.

Best Regards,

Marco

FUNCTION SendMail()

LOCAL oOutLook,oMailItem,oRecip,oAttach

oOutLook := CreateObject( "Outlook.Application" )

oMailItem := oOutLook:CreateItem( 0 )

oRecip := oMailItem:Recipients
oRecip:Add( "noc@softwarexp.co.uk" )

oMailItem:Subject := "Testing fw"

oMailItem:Body := "FW Body!" + CRLF + CRLF

oAttach := oMailItem:Attachments
oAttach:Add( "c:\sendmail.txt" )

oMailItem:Send()

RETURN NIL
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Interactive mail via Outlook

Postby ask » Mon Feb 20, 2006 2:42 pm

Marco Turco wrote:Hi,
is there a way to show the standard Outlook dialog to send an email via OLE ? I use this routine but the email start immediatly without the feature for the user to modify/integrate the email contents.

Thanks in advance.

Best Regards,

Marco

FUNCTION SendMail()

LOCAL oOutLook,oMailItem,oRecip,oAttach

oOutLook := CreateObject( "Outlook.Application" )

oMailItem := oOutLook:CreateItem( 0 )

oRecip := oMailItem:Recipients
oRecip:Add( "noc@softwarexp.co.uk" )

oMailItem:Subject := "Testing fw"

oMailItem:Body := "FW Body!" + CRLF + CRLF

oAttach := oMailItem:Attachments
oAttach:Add( "c:\sendmail.txt" )

oMailItem:Send()

RETURN NIL


Use Display property

e.g:
.
.
.
oMailItem:Body := "FW Body!" + CRLF + CRLF

oAttach := oMailItem:Attachments
oAttach:Add( "c:\sendmail.txt" )

oMailItem:Display()
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Postby Marco Turco » Mon Feb 20, 2006 3:54 pm

Thanks you Ask.

The Outlook send dialog appairs now (using Display(.t.) - with only Display() an error appairs)

but if I close the dialog without send the email then this error appairs:

-----------
Application
===========
Path and name: K:\pigc\PIGC.Exe (32 bits)
Size: 6,524,416 bytes
Time from start: 0 hours 0 mins 16 secs
Error occurred at: 20/02/06, 16:51:21
Error description: Error Outlook.Application:CREATEITEM/9 Proprietà di sola lettura.: DISPLAY
Args:
[ 1] = L .T.

Stack Calls
===========
Called from TOLEAUTO:DISPLAY(0)
--------------

Do I need to include any special lib ?

Marco
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby James Bott » Mon Feb 20, 2006 9:19 pm

Marco,

Try this:

Code: Select all  Expand view
#include "fivewin.ch"
#include "mail.ch"

function main()
   sendMail({"jbott@compuserve.com"},"Test mail", "Message...", {"c:\config.sys"})
return nil


function sendMail(aTo,cSubject,cMsg,aFiles)
local oMail

default cSubject:=""

DEFINE MAIL oMail ;
        SUBJECT OemToAnsi(cSubject) ;
        TEXT OemToAnsi(cMsg);
        FROM USER  // Use this to get the dialog box for the user

   AADD( oMail:aRecipients, aTo )

   if aFiles!=nil
      oMail:aFiles:=ACLONE(aFiles)
   endif

   ACTIVATE MAIL oMail

   IF oMail:nRetCode#0
      MsgAlert("The message could not be sent!","Alert")
  ENDIF

return nil
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Marco Turco » Tue Feb 21, 2006 11:20 am

Hi James,
I always used the mapi class to send emails without problems
but it now doesn't runs anymore with Outlook 2003 due to a Microsoft bug . This bug is reported in the article 872896.

-- From MSN ---

The From field is blank in an e-mail message that is in the Sent Items folder in Outlook 2003
View products that this article applies to.
Article ID : 872896
Last Review : January 4, 2005
Revision : 2.0
SYMPTOMS
When you send an e-mail message in Microsoft Office Outlook 2003, the From field in the e-mail message that is in your Sent Items folder may not contain any e-mail addresses. Also, you may receive a non-delivery report (NDR) message in your Inbox folder that is similar to the following:
Your message did not reach some or all of the intended recipients.

Subject: test
Sent: 6/30/2004 1:48 PM

The following recipient(s) could not be reached:

'User@Domain.com' on 6/30/2004 1:48 PM
None of your e-mail accounts could send to this recipient.
CAUSE
This issue occurs if all the following are true:• You are using Microsoft Office Outlook 2003 Service Pack 1 (SP1).
• You are using either a Post Office Protocol version 3 (POP3) account or an Internet Message Access Protocol (IMAP) account.
• The e-mail message was sent to one or more people who are not in your domain.
• Outlook 2003 is configured to receive an NDR message for all recipients.

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Currently, there is no resolution for this issue. Because the e-mail message was not delivered to any recipients, the fact that you have an empty From field in an-email message that is in your Sent Items folder would be known only by you.

--------------------------------------------------------------------------------

APPLIES TO
• Microsoft Office Outlook 2003, Service Pack 1 (SP1)

Back to the top

Keywords: kbtshoot kbprb KB872896
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby ask » Tue Feb 21, 2006 12:56 pm

Marco Turco wrote:Thanks you Ask.

The Outlook send dialog appairs now (using Display(.t.) - with only Display() an error appairs)

but if I close the dialog without send the email then this error appairs:

-----------
Application
===========
Path and name: K:\pigc\PIGC.Exe (32 bits)
Size: 6,524,416 bytes
Time from start: 0 hours 0 mins 16 secs
Error occurred at: 20/02/06, 16:51:21
Error description: Error Outlook.Application:CREATEITEM/9 Proprietà di sola lettura.: DISPLAY
Args:
[ 1] = L .T.

Stack Calls
===========
Called from TOLEAUTO:DISPLAY(0)
--------------

Do I need to include any special lib ?

Marco



Hi Marco
I don't know if this has to do with fwh version (i have 2.7 february 2006 and xharbour 0.99.60) but the bellow example is working perfectly

#include "fivewin.ch"


FUNCTION SendMail()

LOCAL oOutLook,oMailItem,oRecip,oAttach

oOutLook := CreateObject( "Outlook.Application" )

oMailItem := oOutLook:CreateItem( 0 )

oRecip := oMailItem:Recipients
oRecip:Add( "mail@mail.com" )

oMailItem:Subject := "Testing fw"

oMailItem:Body := "FW Body!" + CRLF + CRLF


oMailItem:display(.t.)

RETURN NIL
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Postby James Bott » Tue Feb 21, 2006 4:43 pm

Marco,

I always used the mapi class to send emails without problems
but it now doesn't runs anymore with Outlook 2003 due to a Microsoft bug . This bug is reported in the article 872896.


Now I remember, we discussed this a short time ago. And if I remember correctly, you found that upgrading to SP2 solved the problem.

Are you now looking for a solution that doesn't require the SP2 upgrade, or?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Marco Turco » Tue Feb 21, 2006 6:26 pm

Hi James,
as I read on MSN
Microsoft released only a patch to solve this problem in Exchange
but in Outlook there is not a solution at this moment
so I am going to manage the email sending via OLE if Outlook is installad as client and via MAPI if it is not installed.

However I take a look into the Fivewin tMail class
and there is a "aOrigin" parameter but Outlook doesn't send the email also with the email account passed as aOrigin.

The problem appairs with Outlook 2003 sp2 also.


Marco
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby Marco Turco » Tue Feb 21, 2006 6:42 pm

Hi Ask,
nothing to do.
Your code give me an error if I close the Outlook send dialog without sending the email. There isn't any problem if I send the email.

I work with xHarbour 0.99.50 and FWH26
however I still bought the update to FWH27 so I hope this problem could be solved with this update.

Thanks

Best Regards,

Marco
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 22 guests