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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPI Sending an email with an attachment. 1

Status
Not open for further replies.

nicktherod

Programmer
Nov 10, 2000
19
CA
I am having a problem with MAPI. I have written my code and incuded mapi.h, I have also linked MAPI32.LIB to the project, but i am still getting a linking error

Linking...
emailView.obj : error LNK2001: unresolved external symbol _MAPISendMail@20
Debug/email.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

I have read somewhere about MAPI.INI, but am unsure what i should do with it, could someone point me in the right direction please.

Many Thanks

Nick
 
I had the same problem but it's a question of MAPI32.LIB which version might be not compatible with the DLL. Just try to call the function without the MAPI32.LIB like this :
LPMAPILOGON lpfnMAPILogon;
LPMAPISENDMAIL lpfnMAPISendMail;
LPMAPILOGOFF lpfnMAPILogoff;


MapiRecipDesc recipient =
{
0, MAPI_TO,
"Friend", "SMTP:toto@titi.com",
0, NULL
};

MapiMessage message =
{
0, "Warning Mail 1",
"Hello,Ol how are you\n",
NULL, NULL, NULL, 0, NULL, 1, &recipient, 0, NULL
};
// HERE YOU CALL THE FUNCTIONS OF THE LIBRARY WITHOUT .LIB
LHANDLE lhSession;
HINSTANCE hMAPILib;

hMAPILib = LoadLibrary("MAPI32.DLL");
lpfnMAPILogon =
(LPMAPILOGON)GetProcAddress(hMAPILib, "MAPILogon");
lpfnMAPISendMail =
(LPMAPISENDMAIL)GetProcAddress(hMAPILib, "MAPISendMail");
lpfnMAPILogoff =
(LPMAPILOGOFF)GetProcAddress(hMAPILib, "MAPILogoff");


(*lpfnMAPILogon)(0, NULL, NULL, 0 , 0, &lhSession);
(*lpfnMAPISendMail)(lhSession, 0, &message, 0, 0);
(*lpfnMAPILogoff)(lhSession, 0, 0, 0);

FreeLibrary(hMAPILib);

Hope that helps.
Olivier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top