003
22.07.2003, 17:04 Uhr
Uwe
C/C++ Master (Administrator)
|
Hallo, bis auf die Sicherheitsabfrage von Outlook Express und der FW scheint es zu funktionieren (aber eben nicht über/mit Automation).
C++: |
#include <mapi.h> #pragma comment(lib,"mapi32.lib") //............... BOOL Send(CHAR *lpszFrom, CHAR *lpszTo, CHAR *lpszSubject, CHAR *lpszMessage) { typedef ULONG (FAR PASCAL *FPP_Logon)(ULONG,LPTSTR,LPTSTR,FLAGS,ULONG,LPLHANDLE); typedef ULONG (FAR PASCAL *FPP_SendMail)(LHANDLE,ULONG,lpMapiMessage,FLAGS,ULONG); typedef ULONG (FAR PASCAL *FPP_Logoff)(LHANDLE,ULONG,FLAGS,ULONG);
BOOL bIsSend = FALSE;
HINSTANCE hMAPI = ::LoadLibrary(_T("mapi32.dll")); if(0==hMAPI) return bIsSend;
FPP_Logon MAPILogon = (FPP_Logon)::GetProcAddress(hMAPI,"MAPILogon"); FPP_SendMail MAPISendMail = (FPP_SendMail)::GetProcAddress(hMAPI,"MAPISendMail"); FPP_Logoff MAPILogoff = (FPP_Logoff)::GetProcAddress(hMAPI,"MAPILogoff");
const BOOL bLoad = (0!=MAPILogon)&&(0!=MAPISendMail)&&(0!=MAPILogoff); ASSERT(bLoad);
if(bLoad){ LHANDLE lhSession = 0; VERIFY(SUCCESS_SUCCESS==MAPILogon(0,0,0,MAPI_NEW_SESSION,0,&lhSession)); ASSERT(0!=lhSession);
MapiRecipDesc mapirecip; ::ZeroMemory(&mapirecip,sizeof(mapirecip)); mapirecip.ulRecipClass = MAPI_TO; mapirecip.lpszName = lpszTo;
MapiMessage message; ::ZeroMemory(&message,sizeof(message)); message.lpszSubject = lpszSubject; message.lpszNoteText = lpszMessage; message.nRecipCount = 1; message.lpRecips = &mapirecip;
bIsSend = SUCCESS_SUCCESS == MAPISendMail(lhSession,0,&message,0,0);
VERIFY(SUCCESS_SUCCESS==MAPILogoff(lhSession,0,0,0));
}
::FreeLibrary(hMAPI);
return bIsSend; }
void CMapiDlg::OnOK() { CHAR *lpszFrom, *lpszTo, *lpszSubject, *lpszMessage; lpszFrom = "***@****.de"; lpszTo = "***@****.de"; lpszSubject = "Nachricht"; lpszMessage = "Mal sehen ob der Kram funzt! Falls das ankommt ist alles Banane..."; Send(lpszFrom,lpszTo,lpszSubject,lpszMessage); //CDialog::OnOK(); }
|
-- "Es ist schwierig, ein Programm wirklich idiotensicher zu machen, weil Idioten so genial sind."
Bis dann... Uwe |