Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 71083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:49:56+00:00 2026-05-10T19:49:56+00:00

ShellExecute() allows me to perform simple shell tasks, allowing the system to take care

  • 0

ShellExecute() allows me to perform simple shell tasks, allowing the system to take care of opening or printing files. I want to take a similar approach to sending an email attachment programmatically.

I don’t want to manipulate Outlook directly, since I don’t want to assume which email client the user uses by default. I don’t want to send the email directly, as I want the user to have the opportunity to write the email body using their preferred client. Thus, I really want to accomplish exactly what Windows Explorer does when I right click a file and select Send To -> Mail Recipient.

I’m looking for a C++ solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:49:56+00:00Added an answer on May 10, 2026 at 7:49 pm

    This is my MAPI solution:

    #include <tchar.h> #include <windows.h> #include <mapi.h> #include <mapix.h>  int _tmain( int argc, wchar_t *argv[] ) {     HMODULE hMapiModule = LoadLibrary( _T( 'mapi32.dll' ) );      if ( hMapiModule != NULL )     {         LPMAPIINITIALIZE lpfnMAPIInitialize = NULL;         LPMAPIUNINITIALIZE lpfnMAPIUninitialize = NULL;         LPMAPILOGONEX lpfnMAPILogonEx = NULL;         LPMAPISENDDOCUMENTS lpfnMAPISendDocuments = NULL;         LPMAPISESSION lplhSession = NULL;          lpfnMAPIInitialize = (LPMAPIINITIALIZE)GetProcAddress( hMapiModule, 'MAPIInitialize' );         lpfnMAPIUninitialize = (LPMAPIUNINITIALIZE)GetProcAddress( hMapiModule, 'MAPIUninitialize' );         lpfnMAPILogonEx = (LPMAPILOGONEX)GetProcAddress( hMapiModule, 'MAPILogonEx' );         lpfnMAPISendDocuments = (LPMAPISENDDOCUMENTS)GetProcAddress( hMapiModule, 'MAPISendDocuments' );          if ( lpfnMAPIInitialize && lpfnMAPIUninitialize && lpfnMAPILogonEx && lpfnMAPISendDocuments )         {             HRESULT hr = (*lpfnMAPIInitialize)( NULL );              if ( SUCCEEDED( hr ) )             {                 hr = (*lpfnMAPILogonEx)( 0, NULL, NULL, MAPI_EXTENDED | MAPI_USE_DEFAULT, &lplhSession );                  if ( SUCCEEDED( hr ) )                 {                     // this opens the email client with 'C:\attachment.txt' as an attachment                     hr = (*lpfnMAPISendDocuments)( 0, ';', 'C:\\attachment.txt', NULL, NULL );                      if ( SUCCEEDED( hr ) )                     {                         hr = lplhSession->Logoff( 0, 0, 0 );                         hr = lplhSession->Release();                         lplhSession = NULL;                     }                 }             }              (*lpfnMAPIUninitialize)();         }          FreeLibrary( hMapiModule );     }      return 0; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create and then open a txt file using the ShellExecute command.
I have a VB6 application which opens files with their associated application using: ShellExecute(0,
In C++, what are the main differences between system() and shellexecute() ? In what
I use ShellExecute to open files. On a single machine among 2000+ users I
Shell Execute has the following signature : HINSTANCE ShellExecute( __in_opt HWND hwnd, __in_opt LPCTSTR
is there any way I can install a system-wide ShellExecute hook using C++ without
If I run a process with ShellExecute (or in .net with System.Diagnostics.Process.Start() ) the
How can I perform the equivalent of shellexecute() in Lazarus for a Mac?
What I ultimately want to do is ShellExecute() a command-line program every time a
i want to call this.. well as good as ShellExecute(Handle, 'open', 'c:\Windows\notepad.exe', nil, nil,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.