MAPI and Outlook 2003

Postby Randal » Tue Feb 28, 2006 5:30 pm

Customer is using Outlook 2003 w/SP2. He gets a msg prompting him to select a profile, there is only one defined. The email ends up in the outbox but he gets a msg that states- The following recipient(s) could not be reached:

The email address shown is enclosed in ' ', I think this may be why it's not being sent.

Unfortunately, the customer is in another state so it's a little difficult to diagnose. Any other ideas?

Thanks,
Randal Ferguson
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby James Bott » Tue Feb 28, 2006 5:42 pm

Randal,

Is this a 16bit FW application? If so, I had this problem with all versions of Outlook. The only solution I could come up with was to use an external 32bit FWH app to send the mail (called from the 16bit app).

If it is not a 16bit app, then how are you formatting the email address you are sending to MAPI?

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

Postby Randal » Tue Feb 28, 2006 9:45 pm

James,

This is a 16-bit app but I'm calling a 32-bit program written in FWH/xHarbour and passing the email address as a command line argument. This works fine with Outlook Express and other mapi programs.

Thanks,
Randal
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby James Bott » Tue Feb 28, 2006 10:01 pm

Randal,

So, if I understand you correctly, you are calling the MAPI client from a 32bit FWH program? Can we see the code doing the calling?

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

Postby Randal » Tue Feb 28, 2006 11:43 pm

James,

Here it is:

FUNCTION SendEmail(cToWhom)

Local afiles:={},cSubject,cBody,cFiles
Local path:="\"+curdir()+"\",oMail
LOCAL nRetCode

IF empty(cToWhom)
Msginfo("Invalid Email Address!")
RETURN NIL
ENDIF

if ! Empty(cFiles)
aadd(afiles,{cfiles,""})
endif

* nRetCode := MAPILogOn()

/* IF nRetCode == -1
MsgStop( "Error initializing mail" )
RETURN NIL
ENDIF */

nRetCode = MAPISendMail( , , ,;
DToS( date() ) + " " + time(), ;
, ,.t.,;
, { alltrim( cToWhom )}, )

IF nRetCode == 25
MsgStop("Invalid email address!", "Problem")
ELSEIF nRetCode = 1
* MsgStop("Operation Cancelled!", "Problem")
ELSEIF nRetCode <> 0
MsgStop(nRetCode, "Problem - MAPI Return Code")
ENDIF

MAPILogOff()

return nil
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby James Bott » Wed Mar 01, 2006 2:46 am

Randal,

It looks like you have cToWhom as the 8th parameter. I think that if you don't provide a name as the 7th parameter, then you are supposed to put the address in the 7th postion. I am not sure about this, but it is worth a try.

Also below is another method of sending MAPI mail using only xHarbour that was posted by Ron Pinkas some time ago. Perhaps that will work.

James

Code: Select all  Expand view
From: "Ron Pinkas" <Ron@remove-this.xharbour.com>
Subject: Re: How can I send mail ?
Date: Tuesday, March 23, 2004 11:04 AM

Here is a sample that should work with ANY provider of SimpleMAPI, including
Outlook and Oulook Express, as long as SimpleMAPI is properly configured.

//----------------------------------------------------------//
PROCEDURE Mail()

   LOCAL oSession, oMessage

   TRY
     oSession := CreateObject( "MSMAPI.MAPISession" )
     oSession:SignOn()
   CATCH
     Alert( "SimpleMapi not avilable." )
     BREAK
   END

   TRY
     oMessage := CreateObject( "MSMAPI.MAPIMessages" )
   CATCH
     Alert( "MSMAPI.Messages faild!" )
     BREAK
   END

   WITH OBJECT oMessage
        :SessionID := oSession:SessionID
        :Compose()

        :RecipAddress := "tests@xharbour.org"
        :AddressResolveUI := .T.
        :ResolveName()

        :MsgSubject := "email from xHarbour"
        :MsgNoteText := "Hi Brian, here it is..."

        :AttachmentIndex := 0
        :AttachmentPosition := 0
        :AttachmentPathName := "c:\xharbour\tests\test.prg"

        :Send( .F. ) // .T. Interactive or .F. for automated.
   END

   oSession:SignOff()

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

Postby Randal » Wed Mar 01, 2006 3:15 pm

James,

Thanks for the sample code. Is there some procedure to insure SimpleMapi is configured correctly?

According to the tmail source for FWH 2.7 it looks like the recipient should be the 9th parameter, or 8th if no origin name is provided?

::nRetCode = MAPISendMail( ::cSubject, ::cNoteText, ::cMsgType,;
DToS( ::dDate ) + " " + ::cTime,;
::cConversationID, ::lReceipt, ::lFromUser,;
::aOrigin, ::aRecipients, ::aFiles )

Thanks,
Randal
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby James Bott » Wed Mar 01, 2006 4:20 pm

Randal,

>Is there some procedure to insure SimpleMapi is configured correctly?

That I don't know.

According to the tmail source for FWH 2.7 it looks like the recipient should be the 9th parameter, or 8th if no origin name is provided?

Well, I can program, but I can't count. My mistake. aOrigin is either the name if you also have an address, or it is the address if you don't provide a name.

Let us know if that works.

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

Postby Randal » Thu Mar 02, 2006 3:12 pm

James,

Making the email address the 9th parameter causes a MAPI Error Code 2.

I compiled the SimpleMAPI sample you posted and I get the error message "SimpleMapi not available".

Thanks,
Randal Ferguson
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby James Bott » Fri Mar 03, 2006 1:28 am

Randal,

>Making the email address the 9th parameter causes a MAPI Error Code 2.

It was already in the 9th slot. Did you mean 8th, or did you put it in the 10th by mistake?

>I compiled the SimpleMAPI sample you posted and I get the error message "SimpleMapi not available".

Maybe this will help:

If sending or receiving mail is not the primary function of your application, you can test the presence of simple MAPI in a system without incurring high cost of trying to load a DLL by testing the value of the MAPI variable. It is 1 if simple MAPI is installed. The variable is located in the [mail] section of Win.ini on 16-bit Windows and Windows NT version 3.51 and earlier; it is under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem in the registry on Windows 95 and Windows NT 4.0 and later.


Taken from this page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpsimplemapi.asp

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

Postby VeRCE » Fri Mar 03, 2006 3:34 am

Marco Turco wrote:I found th problem on msn.
It is a bug on Outlook 2003 sp1.
Thanks.
Marco


Where can i download the fix ???
Juan Carlos Salinas Ojeda
México. D.F.
-------------------------------------------------
User avatar
VeRCE
 
Posts: 219
Joined: Fri Nov 04, 2005 2:34 pm
Location: Mexico D.F.

Postby Davide » Thu Mar 16, 2006 10:27 pm

Marco Turco wrote:I found the problem on msn.
It is a bug on Outlook 2003 sp1.


Marco, I've the same problem with Outlook 2002.
I'm quite sure you've posted the URL which explains the problem, but I can no more find it.

BTW, did you find a solution ?

Hi,
Davide.
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Postby Marco Turco » Fri Mar 17, 2006 8:22 am

Hi Davide,
unfortunately Microsoft released a fix only for exchange server
and not for Outlook.

The only turnaround I found is to send email via OLE if Outlook is installed
otherwise I use the MAPI subset system.

You can make this using this function:

#include "FiveWin.ch"
#include "Mail.ch"

FUNCTION Interactivemessage()
paramet cSubject, cBody, aTo, aFiles, lDirectSend

LOCAL oOutLook,oMailItem,oRecip,oAttach,i

if lDirectSend=NIL
lDirectSend:=.f.
endif

if cSubject=NIL
cSubject:=""
endif
if cBody=NIL
cBody:=""
endif
if aFiles=NIL
aFiles:=array(0,0)
endif

lOffice:=.t.
TRY
oOutLook := CreateObject( "Outlook.Application" )
oMailItem := oOutLook:CreateItem( 0 )
oRecip := oMailItem:Recipients
CATCH
lOffice:=.f.
END

if lOffice
for i:=1 to len(aTo)
oRecip:Add( aTo[i,2] )
next

oMailItem:Subject := cSubject

oMailItem:Body := cBody

if len(aFiles)>0
oAttach := oMailItem:Attachments
for i:=1 to len(aFiles)
oAttach:Add( aFiles[i,1] )
next
endif

if lDirectSend
oMailItem:Send()
else
oMailItem:display(.t.)
endif
else
for i:=1 to len(aTo)
aTo[i,1]:=alltrim(aTo[i,2])
aTo[i,2]:=alltrim(aTo[i,2])
next


oMail:=tMail():New( cSubject,cBody,,,,, .f., .t.,,aTo,aFiles)

ACTIVATE MAIL oMail
retcode:=oMail:nRetCode
endif
return


Best Regards,

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

Postby Davide » Fri Mar 17, 2006 12:01 pm

Marco Turco wrote:unfortunately Microsoft released a fix only for exchange server
and not for Outlook.


Could you please post the URL ?

The only turnaround I found is to send email via OLE if Outlook is installed
otherwise I use the MAPI subset system.


Thank you. I'll try it.

Hi, Davide.
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests