Partager via


MailComposeMessage

4/8/2010

The MailComposeMessage function begins the message composition process by invoking either the Messaging Account Picker or the Compose Message Form, for the user.

Syntax

HRESULT MailComposeMessage(
  MAILCOMPOSEFIELDS* pmcf
);

Parameters

  • 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.

Return Value

This function returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:

  • S_OK
    The call succeeded.

Remarks

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.

Note

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.

Code Example

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;

Comments

You can restrict the user to sendin e-mail only, by using a mailto URL format. This is useful when you want to send long e-mail messages, or when you want to allow multiple recipients (which does not work with SMS messages).

Code Example

The following code example shows the MAILCOMPOSEFIELDS values to set to specify that the message be sent from a particular messaging account.

mcf.pszAccount = TEXT("ActiveSync");
mcf.dwFlags = MCF_ACCOUNT_IS_TRANSPORT;

Comments

You can specify either the name of the account, or the transport.

Requirements

Header cemapi.h
Library cemapi.lib
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Reference

MAPI Functions
MAILCOMPOSEFIELDS
MAPI Compose Field Flags

Other Resources

Messaging