The MailComposeMessage function begins the message composition process by invoking either the Messaging Account Picker or the Compose Message Form, for the user.
HRESULT MailComposeMessage( MAILCOMPOSEFIELDS* pmcf );
[in] Reference to a MAILCOMPOSEFIELDS structure. The Messaging Application displays either the Account Picker, or a Compose Message Form—which one depends on the values in this structure. Additoinally, the Compose Message form can be pre-filled with the values in this structure. Can be NULL if the form has no pre-filled values.
This function enables you to invoke the message composition process in one of three ways, depending on the values you set for MAILCOMPOSEFIELDS members:
Restrict users to creating new e-mail messages, and allow them to pick an e-mail account to use.
Restrict users to creating new SMS messages, and immediately invoke the SMS Compose Message Form.
Allow users to choose between E-mail and SMS. If they chose to create a new e-mail message, then they would pick an e-mail account to use. If they chose to create a new SMS message, then the SMS Compose Message Form would appear.
The MAILCOMPOSEFIELDS structure, along with the available accounts in Messaging, determines whether the Account Picker or Compose Message Form is displayed.
You can also specify which account is used to send this message. You can specify either the name of the account or the transport to use. You can also specify to send by using a mailto URL format.
This function is asynchronous. It returns before the form has been displayed, but will validate that the transport specified is correct and that the attachments specified exist. If the attachments do not exist, the function returns an appropriate error code.
|If a body is specified, then no signature is shown associated with the account. If no body is specified, the signature associated with the account is shown.|
Only one attachment is allowed to be added to a message.
You can use the MCF_ACCOUNT_IS_TRANSPORT MAPI Compose Field flag to determine whether the account is a transport. For more information, see the MAILCOMPOSEFIELDS structure.
The following code example shows the MAILCOMPOSEFIELDS values that you would set if you wanted the user to choose the messaging account to use, while also excluding the SMS transport.
mcf.pszAccount = NULL; mcf.dwFlags = MCF_MAILTO_FORMAT;