(WinAPI) SMTP



  • Hi

    Wie kann ich diesen Code anwenden?

    Was macht er eigentlich ?

    Danke

    #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    = "mo@edvwl.de";
        rdOriginator.ulEIDSize      = 0;
        rdOriginator.lpEntryID      = NULL;
    
        rdRecipient[0].ulReserved   = 0;
        rdRecipient[0].ulRecipClass = MAPI_TO;
        rdRecipient[0].lpszName     = "rdRecipient[0]";
        rdRecipient[0].lpszAddress  = "mo@edvwl.de";
        rdRecipient[0].ulEIDSize    = 0;
        rdRecipient[0].lpEntryID    = NULL;
    
        pfnSendMail(lHnd, NULL, &mapimsg, 0, 0);
        pfnLogoff(lHnd, 0, 0, 0);
    
        FreeLibrary(hDll);
    
      return(0);
    }
    


  • Hi

    Ich habe mir den Rückgabewert angeschaut. Aber mir fällt nix auf und ich habe nix gefunden wo ich was lesenkann darüber.

    Warum öffnet sich kein E-Mail Programm ?

    Danek





  • Hallo,
    lies das: Wohin mit meiner Frage?

    Wenn du fertig bist, lies den Text nocheinmal. Danach lies ein paar Tutorials und Bücher.

    Es ist völlig sinnlos irgendwelchen Code zu kopieren, wenn man nicht mal weiß, was der Code macht. Ein Schritt nach dem anderen.


Anmelden zum Antworten