Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MAPISendMail and attachments

133 views
Skip to first unread message

Andreas Sander

unread,
Jul 5, 1999, 3:00:00 AM7/5/99
to
I use MAPISendMail to send a message with a text file as attachment. As long
as i try to receive the message with MS-Exchange everything works well but
if i try to receive the message with Outlook Express the attachment is
missing.

I found out, thar the attachment is coded as

Content-Type: application/ms-tnef
Content-Transfer-Encoding: base64

in the MIME file that is send with Exchange. But it should be

Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

so it can be read by every e-mail client.

Has anyone an idea what i am doing wrong?

Here is the code of my test program:

HINSTANCE hlibMAPI = LoadLibrary("MAPI32.DLL"); // 32 bit clients

send = (LPMAPISENDMAIL) GetProcAddress(hlibMAPI, "MAPISendMail");
logon = (LPMAPILOGON) GetProcAddress(hlibMAPI, "MAPILogon");
logoff = (LPMAPILOGOFF) GetProcAddress(hlibMAPI, "MAPILogoff");

err = logon((ULONG) m_hWnd, // Window Handle
NULL, // Profile
NULL, // Password
MAPI_LOGON_UI, // Login Dialog
0, // Reserverd
&session);


MapiFileDesc attachment = {0, // ulReserved, must be 0
0, // no flags;
(ULONG)-1, // position not specified
"D:\\ERROR.TXT", // pathname
"ERROR.TXT", // original filename
NULL}; // MapiFileTagExt unused

MapiRecipDesc receiver = {0, //reserverd
MAPI_TO, // Receiver
"Andreas Sander", // Receiver Name
"SMTP:asander@local", // e-mail Address
0, // No Entry ID
NULL}; // No Entry ID

MapiMessage note = {0, // reserved, must be 0
NULL, // no subject
NULL, // no note text
NULL, // NULL = interpersonal message
NULL, // no date; MAPISendMail ignores it
NULL, // no conversation ID
0L, // no flags, MAPISendMail ignores it
NULL, // no originator, this is ignored too
1, // One recipients
&receiver, // recipient array
1, // one attachment
&attachment}; // the attachment structure


err = send (session, // use explicit session.
0L, // ulUIParam; 0 is always valid
&note, // the message being sent
0, // send without further dialogs
0L); // reserved; must be 0


err = logoff(session, // Session
(ULONG) m_hWnd, // Window Handle
0, // Reserved
0 // Reserved
);

FreeLibrary(hlibMAPI);


Jacob de Bruin

unread,
Jul 5, 1999, 3:00:00 AM7/5/99
to
You are not doing anything wrong but you have to much hope on the
compatiblity of MS products with other MS products.
Outlook Express does not understand the Microsoft proprietary
application\ms-tnef content type.
It does not see the nameless (winmail.dat) rich text attachment sent by
Exchange (or Outlook 97 and 98).

Forgive me to recycle here a reply I sent on some earlier question.

More MS info on this item you will find in the article "XFOR: Preventing
WINMAIL.DAT Sent to Internet Users"
(http://support.microsoft.com/support/kb/articles/Q138/0/53.asp)
- - - - - - - - - - - - -
We have been using Simple MAPI for a Win32 Console app and tested it with
OE4 (set to "default simple MAPI client"), Outlook97 and Outlook98. Can't
help you with OE5.
We tested under Windows95 and Windows98 and dit not see different behaviour
of our application).

All of these SEEM to be Simple MAPI compliant, however they do not always
interoperate.

First you have to know that if OE4 is set to default Simple MAPI client it
renames MAPI32.DLL (comes with windows setup for Exchange for example) to
MAPI32.OE and installs a 'tiny' MAPI32.DLL.
Setting this option to OE4 and installing Outlook is a risky business: you'd
better not use MAIL over OE4 and Outlook on the same machine.
You may have to deinstall and reinstall everything because MAPI32.DLL (the
one you will use writing programs with Simple MAPI) may be of a wrong
version.
I understand OE5 works similarly (From
newsgroup:microsoft.public.win32.programmer.messaging "Simple MAPI /CMC
:Microsoft destroys working programs" by aLUNZ ).

We always sent messages to addresses like "name[SMTP:mailbox@domain]" (the
one-off address, so no look-up in the local address book).
Both Outlooks encapsulate the optional message text and any file attachments
(and more) in one single rich text attachment (nameless, implicit
'winmail.dat' I think) with content-type=application\ms-tnef.
To prevent this you would have to address to an alias name "name" (instead
of "name[SMTP:...]", where name must be found in the address book and has
the 'send rich text' set to NEVER.
It SEEMS (somebody told me this but as we had not influence there we did not
investigate) to depend on the implementation on the mail server side, but in
our case this single attachment was delivered as-is and was not visible if
received by a client using OE4: we simply receive an empty message with a
subject only.
OE4 does not support the Microsoft proprietary application\ms-tnef
content-type (there must be some info on the technet, but I cannot recall
where).
If such a message received by OE4 is exported to an Outlook folder the
original message text and attachments are visible again.

We also found that sometimes the first (and only the first if sent using
Simple MAPI) mail from a newly installed Outlook was garbage (unreadable or
worse at the other side).

We have been using Simple CMC in another application. This did not work with
OE4: all CMC function needed are found in the OE4 version of MAPI32.DLL but
return general error (CMC_FAILURE), regardless of the function arguments.

We aware that every new version of MAPI32.DLL installed by any Microsoft
product may effect the behaviour of your program.
It seems to be difficult for Microsoft to create DLL's that are really
backwards-compatible.
This is an understatement, I know.

Hope this helps you.
- - - - - - - - - - - - -

Jacob de Bruin, WALVIS Software BV (NL)

Andreas Sander wrote in message <7lpho5$22dk$1...@euler.space.net>...

0 new messages