-
July 20th, 2001, 04:04 AM
#1
Mapi trouble
so , i have big troubles about mapi :
main error :
---->
Dialog_mail.obj : error LNK2001: unresolved external symbol _MAPISendMail@20
---->
so i have link the Mapi.lib :
---->
C:\Program Files\Microsoft Visual Studio\VC98\LIB\Mapi.lib : fatal error LNK1136: invalid or corrupt file
---->
and i thought it was a bug during installation and i have copy the lib from the Cd but it's change nothing : always the same error ....
If someone could help me , it would be great.
you can also view my code below:
---->
void CDialog_mail::Envoi_message()
{
char * testchar;
testchar = (char *) malloc (256);
char * auxiliaire;
auxiliaire = (char *) malloc (256);
LPTSTR lpszName="Borne de navigation";
m_origine.GetWindowText(testchar,256);
auxiliaire="SMTP:";
for(int i=0;i<256;i++)
auxiliaire[i+5]=testchar[i];
LPTSTR add=auxiliaire;
lpMapiRecipDesc lpOrigin = NULL;
lpOrigin->ulReserved=0;
lpOrigin->ulRecipClass=0;
lpOrigin->lpszName="Borne de navigation";
lpOrigin->lpszAddress=add;
// lpOrigin->ulEIDSize=0;
// lpOrigin->lpEntryID=NULL;
m_destinataire.GetWindowText(testchar,256);
auxiliaire="SMTP:";
for(i=0;i<256;i++)
auxiliaire[i+5]=testchar[i];
add=auxiliaire;
lpMapiRecipDesc lpDest = NULL;
lpDest->ulReserved=0;
lpDest->ulRecipClass=0;
lpDest->lpszName="Borne de navigation";
lpDest->lpszAddress=add;
//lpMapiMessage
m_sujet.GetWindowText(testchar,256);
LPTSTR lpszSub=testchar;
m_texte.GetWindowText(testchar,256);
LPTSTR lpszNote=testchar;
lpMapiMessage lpMessage = NULL;
lpMessage->ulReserved=0;
lpMessage->lpszSubject=lpszSub;
lpMessage->lpszNoteText=lpszNote;
lpMessage->lpszMessageType=NULL;
lpMessage->lpszDateReceived=NULL;
lpMessage->lpszConversationID=NULL;
lpMessage->flFlags=MAPI_RECEIPT_REQUESTED;
lpMessage->lpOriginator=lpOrigin;
lpMessage->nRecipCount=1;
lpMessage->lpRecips=lpDest;
lpMessage->nFileCount=0;
lpMessage->lpFiles=NULL;
ULONG result=MAPISendMail(0,0, lpMessage ,MAPI_DIALOG, 0);
free (testchar);
free (auxiliaire);
if (result==MAPI_E_AMBIGUOUS_RECIPIENT)
MessageBox ("A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set. No message was sent." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_ATTACHMENT_NOT_FOUND)
MessageBox ("The specified attachment was not found. No message was sent." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_ATTACHMENT_OPEN_FAILURE )
MessageBox ("The specified attachment could not be opened. No message was sent." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_BAD_RECIPTYPE )
MessageBox ("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent. " , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_FAILURE )
MessageBox ("One or more unspecified errors occurred. No message was sent." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_INSUFFICIENT_MEMORY )
MessageBox ("There was insufficient memory to proceed. No message was sent." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_INVALID_RECIPS )
MessageBox ("One or more recipients were invalid or did not resolve to any address." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_LOGIN_FAILURE )
MessageBox ("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No message was sent. " , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_TEXT_TOO_LARGE )
MessageBox ("The text in the message was too large. No message was sent." , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_TOO_MANY_FILES )
MessageBox ("There were too many file attachments. No message was sent. " , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_TOO_MANY_RECIPIENTS)
MessageBox ("There were too many recipients. No message was sent. " , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_UNKNOWN_RECIPIENT )
MessageBox ("A recipient did not appear in the address list. No message was sent. " , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==MAPI_E_USER_ABORT )
MessageBox ("The user canceled one of the dialog boxes. No message was sent. " , "Error" , MB_OK | MB_ICONEXCLAMATION);
if (result==SUCCESS_SUCCESS )
MessageBox ("The call succeeded and the message was sent. " , "Message was sent." , MB_OK | MB_ICONEXCLAMATION);
}
---->
arag
*french developper*
-
November 11th, 2001, 02:57 AM
#2
Re: Mapi trouble
MAPISendMail is NOT exported. You need to load MAPI.DLL and get the proc address:
HMODULE hLib=::LoadLibrary("MAPI32.DLL");
if (hLib == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD);
return;
}
ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG);
(FARPROC&)lpfnSendMail = GetProcAddress(hLib, "MAPISendMail");
if (lpfnSendMail == NULL)
{
AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
return;
}
Now call the send mail function:
int nError = lpfnSendMail(0, 0, &message, 0, 0);
ASSERT(nError == SUCCESS_SUCCESS);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|