CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Sending emails

  1. #1
    Join Date
    May 1999
    Location
    Scotland
    Posts
    2

    Sending emails

    I was wondering how I would go about getting a VC++ application to send a file via email when I click a button.

    Thanks


  2. #2
    Join Date
    May 1999
    Posts
    29

    Re: Sending emails

    Hi!

    Here's one of the methods to send an e-mail through a VC program. U can add the code in the Button Clicked Event.Make use of the MAPI32 Dll and header files mentioned below for the same. Refer online help for more info.

    #include <windows.h>
    #include <mapi.h>

    LPMAPILOGON lpfnMAPILogon;
    LPMAPISENDMAIL lpfnMAPISendMail;
    LPMAPILOGOFF lpfnMAPILogoff;

    MapiRecipDesc recipient ={0, MAPI_TO,"Suganya Swaminathan", "SMTP:[email protected]", 0, NULL};

    MapiMessage message ={0, "Greetings", "Hello, Ms.Sukanya!\n",NULL, NULL, NULL, 0, NULL, 1, &recipient, 0, NULL};

    LHANDLE lhSession;
    HANDLE hMAPILib;

    hMAPILib = LoadLibrary("MAPI32.DLL");
    lpfnMAPILogon =(LPMAPILOGON)GetProcAddress(hMAPILib, "MAPILogon");
    lpfnMAPISendMail =(LPMAPISENDMAIL)GetProcAddress(hMAPILib, "MAPISendMail");
    lpfnMAPILogoff =(LPMAPILOGOFF)GetProcAddress(hMAPILib, "MAPILogoff");
    (*lpfnMAPILogon)(0, NULL, NULL, MAPI_NEW_SESSION
    , 0,&lhSession);
    (*lpfnMAPISendMail)(lhSession, 0, &message, 0, 0);
    (*lpfnMAPILogoff)(lhSession, 0, 0, 0);
    AfxMessageBox("Message to the Suganya sent.\n");
    FreeLibrary(hMAPILib);

    Do let me know if this works.

    Regards,
    Sukanya Swaminathan
    Software Engineer
    Aditi Technologies Pvt. Ltd.
    Blore - 80
    Web Page : www.aditi.com




  3. #3
    Guest

    Re: Sending emails

    I tried your program, I am not getting any errors or warnings (except: HMODULE instead of HANDLE for hMAPILib ), but it's not working.
    When I tried to with HANDLE, I got an error of conversion from void* to HINSTANCE* not possible. So, I made that to HMODULE, then I am not getting any errors but it's not working also. let me any wrong...if it has


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured