wie soll sowas funktionieren?
-
Wie kann man es machen, dass die sachen, die sich immer ändern (nachricht, subjekt, empfänger ...) vorher in der console abgefragt werden?
#include <windows.h> #include <mapi.h> #include <tchar.h> #include <stdio.h> #define NUM_ELEMENTS(x) (sizeof((x)) / sizeof((x)[0])) int _tmain(void) { LPMAPISENDMAIL pfnSendMail; MapiRecipDesc rdOriginator; MapiRecipDesc rdRecipient[1]; LPMAPILOGOFF pfnLogoff; LPMAPILOGON pfnLogon; MapiMessage mapimsg; HINSTANCE hDll; LHANDLE lHnd; if(NULL == (hDll = LoadLibrary(TEXT("MAPI32.DLL")))) { _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"), GetLastError()); return(0); } pfnLogon = (LPMAPILOGON) GetProcAddress(hDll, "MAPILogon"); pfnLogoff = (LPMAPILOGOFF) GetProcAddress(hDll, "MAPILogoff"); pfnSendMail = (LPMAPISENDMAIL)GetProcAddress(hDll, "MAPISendMail"); pfnLogon(0, NULL, NULL, 0, 0, &lHnd); mapimsg.ulReserved = 0; mapimsg.lpszSubject = "This is the subject"; mapimsg.lpszNoteText = "This is the message"; mapimsg.lpszMessageType = NULL; mapimsg.lpszDateReceived = NULL; mapimsg.lpszConversationID = NULL; mapimsg.flFlags = 0; mapimsg.lpOriginator = &rdOriginator; mapimsg.nRecipCount = NUM_ELEMENTS(rdRecipient); mapimsg.lpRecips = rdRecipient; mapimsg.nFileCount = 0; mapimsg.lpFiles = NULL; rdOriginator.ulReserved = 0; rdOriginator.ulRecipClass = MAPI_ORIG; rdOriginator.lpszName = "rdOriginator"; rdOriginator.lpszAddress = "test@irgendwo.de"; rdOriginator.ulEIDSize = 0; rdOriginator.lpEntryID = NULL; rdRecipient[0].ulReserved = 0; rdRecipient[0].ulRecipClass = MAPI_TO; rdRecipient[0].lpszName = "rdRecipient[0]"; rdRecipient[0].lpszAddress = "test@irgendwo.de"; rdRecipient[0].ulEIDSize = 0; rdRecipient[0].lpEntryID = NULL; pfnSendMail(lHnd, NULL, &mapimsg, 0, 0); pfnLogoff(lHnd, 0, 0, 0); FreeLibrary(hDll); return(0); }
-
Einlesen und den entsprechenden Struktur-Membern zuweisen:
mapimsg.lpszSubject = malloc(51); scanf("%50s",mapimsg.lpszSubject);
(mit malloc stellst du genug Speicher bereit, mit scan liest du den Inhalt von Tastatur ein)