Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPISendMail with BC5

Status
Not open for further replies.

andylec

Technical User
Feb 2, 2002
110
0
0
GB
Anybody have any ideas how I can use the default email client to create and send a message without the user having to enter anything (I've been using ShellExecute with "mailto:" up until now). I've included mapi.h & linked mapi32 but keep getting an unresolved external error when compiling/linking.

Any ideas/alternatives appreciated.
 
Try this ...

MapiRecipDesc dsc;
TMapiMessage MapiMessage;
Cardinal MError;


try
{

memset(&dsc,0,sizeof(dsc));

dsc.ulRecipClass = MAPI_TO;
dsc.lpszName = " ";
dsc.lpszAddress = 0;
dsc.ulEIDSize = 0;
dsc.lpEntryID = NULL;


MapiMessage.ulReserved = 0L;
MapiMessage.lpszSubject = "Your Subject ...";
MapiMessage.lpszNoteText = "Your text ...;
MapiMessage.lpszMessageType = NULL;
MapiMessage.lpszDateReceived = NULL;
MapiMessage.lpszConversationID = NULL;
MapiMessage.flFlags = 0L;
MapiMessage.lpOriginator = NULL;
MapiMessage.nRecipCount = 1;
MapiMessage.lpRecips = &dsc;
MapiMessage.nFileCount = 0L;
MapiMessage.lpFiles = NULL;

MError=MapiSendMail(0L, reinterpret_cast<unsigned int> (Application->Handle),
MapiMessage, MAPI_DIALOG | MAPI_LOGON_UI | MAPI_NEW_SESSION , 0L);
// --
}
catch( Exception& E )
{
your error stuff.
}
 
Thanks for that. Unfortunately, I don't think I explained myself clearly enough in the first place (D'Oh).

I'm using Borland 5.5, not Builder, and MapiSendMail is the function that causes the problem (when linking).

I get the same problem when trying the same with MinGW.

I'm a little bit new to C/C++, so forgive me if there is areally obvious reason why I can't do this. I'm thinking that I might need a newer/different .def/.a as I can't find MapiSendMail in any of the ones I have.

Up until now I've been using:

ShellExecute(hWnd,
&quot;OPEN&quot;,
&quot;mailto:a@b.com?subject=subj&body=message&quot;,
0, 0, SW_SHOWNORMAL);

It's a bit of a bodge though, and I can't see how to send attachments like this.
Any other means of sending email that uses the default client would be fine, it doesn't need to be MAPI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top