Article View: borland.public.cppbuilder.nativeapi
Article #5481Strange problems with MAPI
From: Mike Collins
Date: Tue, 09 Aug 2005 18:00
Date: Tue, 09 Aug 2005 18:00
66 lines
3353 bytes
3353 bytes
Hi all got a very strange problem with MAPI. I've created a basic wrapper
for MAPI which looks like this:
int TSystemTools::SendEmail(TMapiMessage *MapiMessage)
{
int iRtn = -1;
Cardinal mError;
try
{
mError = MapiSendMail(0, reinterpret_cast<unsigned
int>(Application->Handle),
*MapiMessage,
MAPI_DIALOG|MAPI_LOGON_UI|MAPI_NEW_SESSION, 0);
}
catch(...)
{
}
iRtn = (unsigned __int32)mError;
return iRtn;
}
Not impressive there. Now I call this code in the process of the user
registering / licencing an application from the LicenceDlg. In one
application the code executes no problems, in the orther it doesn't the code
is exactly the same in other (I've cut&pasted to check). It simply returns
MAPI_E_FAILURE which doesn't really help be debug the problem. Calling code
looks like this:
AnsiString szBodyText = "Some registration informtion......"
TMapiMessage MapiMessage;
Cardinal mError;
TMapiRecipDesc MapiRecipients[1];
MapiRecipients[0].ulReserved = 0;
MapiRecipients[0].ulRecipClass = MAPI_TO;
MapiRecipients[0].lpszName = "Sales";
MapiRecipients[0].lpszAddress = sales@softwareassociates.nu;
MapiRecipients[0].ulEIDSize = 0;
MapiRecipients[0].lpEntryID = NULL;
MapiMessage.ulReserved = 0;
MapiMessage.lpszSubject = "Registration request...";
MapiMessage.lpszNoteText = szBodyText.c_str();
MapiMessage.lpszMessageType = NULL;
MapiMessage.lpszDateReceived = NULL;
MapiMessage.lpszConversationID = NULL;
MapiMessage.flFlags = 0;
MapiMessage.lpOriginator = NULL;
MapiMessage.nRecipCount = 1;
MapiMessage.lpRecips = MapiRecipients;
MapiMessage.nFileCount = 0;
MapiMessage.lpFiles = NULL;
int iErr = SystemTools->SendEmail(&MapiMessage);
switch (iErr)
{
// Error messages
}
}
Can anyone see anything that I've done wrong. As I say, I've cut and pasted
the code identically from one app to the other. One works, the other
doesnt. God forgive me for ever upgrading to Win2003. Using C++Builder 6
Ent, all patches, Win2003 all SP, Outlook 2003 :-)
Helppppppppppppppp
Technical Details
Message-ID:
<42f8ed0c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,77e3f800d5e64872,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mike Collins" <its@thebottomofthe.post> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Strange problems with MAPI Date: Tue, 9 Aug 2005 19:00:16 +0100 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.1830 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 81.2.92.14 Message-ID: <42f8ed0c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1123609868 81.2.92.14 (9 Aug 2005 10:51:08 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail