MAPI and Outlook 2003
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
MAPI and Outlook 2003
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
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
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
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
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
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
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
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
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
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
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
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
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
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
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
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.
James
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.
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?I send the email pressing the send button but then Outlook after tried to send the email give me the error "No account available ...."
James
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
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
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
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
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