MAPI and Outlook 2003

MAPI and Outlook 2003

Postby Marco Turco » Mon Jan 23, 2006 10:14 am

Hi,
I need to send an email using MAPI but there is a problem if the email client is Outlook 2003.

An error like "Unable to send message with any account available". There isn't any problem using Outlook 2000 or other mail client.

I read various thread about this problem (MAPI and Outlook) on the FW newsgroup but without a solution.

Is there anyone that know a solution at this moment ?

I attached after the send routine that show the problem.

Thanks in advance.

Best Regards

Marco Turco


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

function InteractiveMessage()
paramet cSubject,cBody,aFrom,aFiles

local oMail

for i:=1 to len(aFrom)
aFrom[i,1]:=alltrim(aFrom[i,2])
aFrom[i,2]:=alltrim(aFrom[i,2])
next

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

ACTIVATE MAIL oMail


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

Postby James Bott » Mon Jan 23, 2006 5:02 pm

Marco,

You didn't mention if the problem is only with one Outlook 2003 machine or all Outlook 2003 machines.

The error message makes me think that perhaps that Outlook is not setup as the default MAPI program on that machine. I not exactly sure how to do it with Outlook, but with OE it is under Tools-Options, General Tab, "Default Message Program" section.

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

Postby Marco Turco » Mon Jan 23, 2006 6:16 pm

James,
thanks you for your suggestion,
however Outlook 2003 is the default MAPI program and
this problem appair on ALL computers with Outlook 2003.

All runs fine with Outlook 2000 instead.

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

Postby James Bott » Mon Jan 23, 2006 7:25 pm

Marco,

OK.

I have found MAPI to be very picky about the format of the data. So, you might try creating the very simplest message you can (using no arrays) and see if you can get that to work with Outlook 2003. If so, then you can add back more parameters until you find the one creating the error.

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

Postby Gale FORd » Mon Jan 23, 2006 8:16 pm

I use Outlook 2003 and FWH Mapi just fine.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby James Bott » Mon Jan 23, 2006 9:41 pm

Marco,

I am wondering about this:

for i:=1 to len(aFrom)
aFrom[i,1]:=alltrim(aFrom[i,2])
aFrom[i,2]:=alltrim(aFrom[i,2])
next

First I was confused by the use of "aFrom." But I see that this is really an array of recipients (To), not senders (From). You are passing it in the recipent position so I guess that works OK regardless.

The second line looks like it might be a typo. You are overwriting the name with the address. Is that what you meant to do? This might be causing an error. Perhaps you meant the line to be:

aFrom[i,1]:=alltrim(aFrom[i,1])

You can use an address without a name, but I'm not sure if you can put an address in both places in the array.

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

Postby Marco Turco » Tue Jan 24, 2006 2:16 pm

Hi James,
I copied the email address into the email name position because sometime an empty email name crash the email client.

However I made this self contained sample that show the problem.
This sample send an email to an email address,
the compose window of Outlook 2003 appair,
I send the email pressing the send button
but then Outlook after tried to send the email give me the error "No account available ...."

Do this sample succesfully runs for you ?
Do I need to include any special lib in xHarbour compilation in order to succesfully access at the MAPI system ?

< For Gale - Could you send me a working sample to send an email ?>

Thanks in advance,

Marco

***

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

function Main

local cSubject,cBody,aTo,aFiles

cSubject:="Send an email through Outlook 2003"

cBody:="Text of mail."

aTo:=array(0,2)
aadd(aTo,{"marco","info@softwarexp.co.uk"})

aFiles:={}

InteractiveMessage(cSubject,cBody,aTo,aFiles)

return nil

function InteractiveMessage()
paramet cSubject,cBody,aTo,aFiles

local oMail

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

ACTIVATE MAIL oMail
return nil
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby James Bott » Tue Jan 24, 2006 4:05 pm

Marco,

I tested your example and it worked fine for me with OE. I do not have Outlook 2003 running on a machine here to test it with.

I do note that you are passing an empy array for aFiles. I would set it to nil if there are no files. I don't know if this could be a problem or not.

I have also found that when you do specify a filename it must contain the complete path. Without the path you get no message dialog or error--at least with some versions of Outlook.
I send the email pressing the send button but then Outlook after tried to send the email give me the error "No account available ...."

This message sounds like Outlook was never setup to attached to a mail server. Can you send a normal mail from the same machine? It only gives this message when you send mail via MAPI?

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

Postby Gale FORd » Tue Jan 24, 2006 5:14 pm

Sample code below works for me with Outlook 2003 SP2
I tested with attached files and multiple addresses

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

function Main
local cSubject,cBody,aTo,aFiles
cSubject:="Send an email through Outlook 2003"
cBody:="Text of mail."
aTo:={"info@softwarexp.co.uk"}
aFiles:={}
InteractiveMessage(cSubject,cBody,aTo,aFiles)
return nil

function InteractiveMessage(cSubject,cBody,aTo,aFiles)
local oMail
local aFileAttach := {}

define mail oMail ;
subject cSubject ;
text cBody ;
from user

if len( aTo ) > 0
oMail:aRecipients := aTo
endif
if aFiles != nil
for nCounter := 1 to len( aFiles )
aadd( aFileAttach, { aFiles[ nCounter ], cFileNoPath( aFiles[ nCounter ] ) } )
next
endif
oMail:aFiles := aFileAttach
ACTIVATE MAIL oMail
return nil
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Marco Turco » Wed Jan 25, 2006 10:12 am

I found the problem on msn.
It is a bug on Outlook 2003 sp1.

Thanks.

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

Postby James Bott » Wed Jan 25, 2006 4:01 pm

Marco,

Great news! I'm making a note for future reference.

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

Postby Randal » Mon Feb 27, 2006 3:33 am

[quote="Marco Turco"]I found the problem on msn.
It is a bug on Outlook 2003 sp1.

Marco,

I have customer with the same problem but they have sp2. Did upgrading to sp2 fix your problem?

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

Postby James Bott » Mon Feb 27, 2006 4:28 am

Randal,

I think the problem is that SP2 fixes the problem when you are using Exchange Server, but if you are using STMP/POP3 it doesn't.

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

Postby Gale FORd » Mon Feb 27, 2006 2:55 pm

I use Outlook 2003 sp2 with pop/smtp and imap ok. We do not have exchange but we host our own email server.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby James Bott » Mon Feb 27, 2006 3:11 pm

Gale,

Thanks for pointing out that it is only sometimes that it doesn't work with POP/SMTP.

I did some searching on this issue and it appears that something gets messed up on a particular PC that causes the problem. It may be a registry issue. One user reported that after he added a new Hotmail account that MAPI stopped working. He removed the HOTMAIL account and MAPI still didn't work. Even removing and reinstalling Outlook didn't solve the problem. This sounds to me like something was changed in the registry which was not removed during the uninstall. It is too bad Microsoft hasn't seen fit to fix the problem. It seems like a serious issue to me.

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests