By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

MAPI mail failure codes??? Where can I find out what failure error code 2 is? How about the rest of the codes?

P: n/a
MLH
I cut a mail function off the m'soft site. Has always worked. However,
I would like to include error codes returned by the sendmail Fn and
be able to understand what they mean. I had my first occasion to
experience a failure and got a code of 2??? Would like to know
just what that means.

Here's how I call the fn...
Result = SendMail((F!Subject), (F!To), (F!CC), (F!Attach),
(F!Message))
And here's the fn.....
Function SendMail (sSubject As String, sTo As String, sCC As String,
sAttach As String, sMessage As String)
Dim i, cTo, cCC, cAttach ' variables holding counts

Dim MAPI_Message As MAPIMessage

' Count the number of items in each piece of the mail message
cTo = CountTokens(sTo, ";")
cCC = CountTokens(sCC, ";")

cAttach = CountTokens(sAttach, ";")

' Create arrays to store the semicolon delimited mailing
' .. information after it is parsed
ReDim rTo(0 To cTo) As String
ReDim rCC(0 To cCC) As String

ReDim rAttach(0 To cAttach) As String

' Parse the semicolon delimited information into the arrays.
ParseTokens rTo(), sTo, ";"
ParseTokens rCC(), sCC, ";"

ParseTokens rAttach(), sAttach, ";"

' Create the MAPI Recip structure to store all the To and CC

' .. information to be passed to the MAPISendMail function
ReDim MAPI_Recip(0 To cTo + cCC - 1) As MapiRecip
' Setup the "TO:" recipient structures
For i = 0 To cTo - 1
MAPI_Recip(i).Name = rTo(i)
MAPI_Recip(i).RecipClass = MAPI_TO
Next i

' Setup the "CC:" recipient structures
For i = 0 To cCC - 1
MAPI_Recip(cTo + i).Name = rCC(i)
MAPI_Recip(cTo + i).RecipClass = MAPI_CC
Next i

' Create the MAPI File structure to store all the file
attachment
' .. information to be passed to the MAPISendMail function
ReDim MAPI_File(0 To cAttach) As MapiFile

' Setup the file attachment structures
MAPI_Message.FileCount = cAttach
For i = 0 To cAttach - 1
MAPI_File(i).Position = -1
MAPI_File(i).PathName = rAttach(i)
Next i

' Set the mail message fields
MAPI_Message.Subject = sSubject
MAPI_Message.NoteText = sMessage
MAPI_Message.RecipCount = cTo + cCC
' Send the mail message
SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(0),
MAPI_File(0), MAPI_LOGON_UI, 0&)

End Function

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
MLH wrote:
I cut a mail function off the m'soft site. Has always worked. However,
I would like to include error codes returned by the sendmail Fn and
be able to understand what they mean. I had my first occasion to
experience a failure and got a code of 2??? Would like to know
just what that means.


Unfortunately it means "FAILURE". Err.LastDLLError may give you more
information or it may not.

Global Const SUCCESS_SUCCESS = 0
Global Const MAPI_USER_ABORT = 1
Global Const MAPI_E_USER_ABORT = MAPI_USER_ABORT
Global Const MAPI_E_FAILURE = 2
Global Const MAPI_E_LOGIN_FAILURE = 3
Global Const MAPI_E_LOGON_FAILURE = MAPI_E_LOGIN_FAILURE
Global Const MAPI_E_DISK_FULL = 4
Global Const MAPI_E_INSUFFICIENT_MEMORY = 5
Global Const MAPI_E_BLK_TOO_SMALL = 6
Global Const MAPI_E_TOO_MANY_SESSIONS = 8
Global Const MAPI_E_TOO_MANY_FILES = 9
Global Const MAPI_E_TOO_MANY_RECIPIENTS = 10
Global Const MAPI_E_ATTACHMENT_NOT_FOUND = 11
Global Const MAPI_E_ATTACHMENT_OPEN_FAILURE = 12
Global Const MAPI_E_ATTACHMENT_WRITE_FAILURE = 13
Global Const MAPI_E_UNKNOWN_RECIPIENT = 14
Global Const MAPI_E_BAD_RECIPTYPE = 15
Global Const MAPI_E_NO_MESSAGES = 16
Global Const MAPI_E_INVALID_MESSAGE = 17
Global Const MAPI_E_TEXT_TOO_LARGE = 18
Global Const MAPI_E_INVALID_SESSION = 19
Global Const MAPI_E_TYPE_NOT_SUPPORTED = 20
Global Const MAPI_E_AMBIGUOUS_RECIPIENT = 21
Global Const MAPI_E_AMBIG_RECIP = MAPI_E_AMBIGUOUS_RECIPIENT
Global Const MAPI_E_MESSAGE_IN_USE = 22
Global Const MAPI_E_NETWORK_FAILURE = 23
Global Const MAPI_E_INVALID_EDITFIELDS = 24
Global Const MAPI_E_INVALID_RECIPS = 25
Global Const MAPI_E_NOT_SUPPORTED = 26

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #2

P: n/a
MLH
<snip>
I found this snippet on the web and was about to come
back here and post it when I found your answer. Thank-you
Lyle (very much) for your assistance.
************************************************** ****
case MAPIError of
MAPI_E_AMBIGUOUS_RECIPIENT:
Showmessage('A recipient matched more than one of the
recipient descriptor structures and MAPI_DIALOG was not set. No
message was sent.');
MAPI_E_ATTACHMENT_NOT_FOUND:
Showmessage('The specified attachment was not found; no
message was sent.');
MAPI_E_ATTACHMENT_OPEN_FAILURE:
Showmessage('The specified attachment could not be
open; no message was sent.');
MAPI_E_BAD_RECIPTYPE:
Showmessage('The type of a recipient was not MAPI_TO,
MAPI_CC, or MAPI_BCC. No message was sent.');
MAPI_E_FAILURE:
Showmessage('One or more unspecified errors occurred;
no message was sent.');
MAPI_E_INSUFFICIENT_MEMORY:
Showmessage('There was insufficient memory to proceed.
No message was sent.');
MAPI_E_LOGIN_FAILURE:
Showmessage('There was no default logon, and the user
failed to log on successfully when the logon dialog box was displayed.
No message was sent.');
MAPI_E_TEXT_TOO_LARGE:
Showmessage('The text in the message was too large to
sent; the message was not sent.');
MAPI_E_TOO_MANY_FILES:
Showmessage('There were too many file attachments; no
message was sent.');
MAPI_E_TOO_MANY_RECIPIENTS:
Showmessage('There were too many recipients; no message
was sent.');
MAPI_E_UNKNOWN_RECIPIENT:
Showmessage('A recipient did not appear in the address
list; no message was sent.');
MAPI_E_USER_ABORT:
Showmessage('The user canceled the process; no message
was sent.');
SUCCESS_SUCCESS:
Showmessage('MAPISendMail successfully sent the
message.');
else
Showmessage('MAPISendMail failed with an unknown error
code.');
end;

As you can see, it gives me clues as to the range of errors returned.
Trouble is, I get numbers returned as error codes and I do not know
what they mean. For instance, I get the number 2. Is there somewhere
on the InterNET I can go see the MAPI error codes and descriptions?
I am using 16-bit MAPI.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.