Compartilhar via


Beginning a MAPI Session

Windows Mobile SupportedWindows Embedded CE Not Supported

9/8/2008

Antes de você pode acessar armazenar uma mensagem, você deve inicializar o subsistema MAPI e log em uma sessão MAPI. Isso proporciona a você uma referência a um objeto interface IMAPISession, que você pode usar para acessar a tabela armazenar mensagem, armazena mensagem mensagem pastas e mensagens.

Para iniciar a sessão MAPI

  1. Incrementa o subsistema MAPI contagem de referência e inicializar dados globais para o MAPI DLL com a função MAPI global MAPIInitialize, da seguinte maneira:

    hr = MAPIInitialize(NULL);
    
  2. Fazer logon em uma sessão com a função MAPI global MAPILogonEx e get uma referência a um objeto interface ICEMAPISession MAPI. Uma vez que você está usando a versão Windows Mobile MAPI e não o área de trabalho versão — declarar o objeto sessão como tipo ICEMAPISessione não tipo IMAPISession. Desde ICEMAPISession Herda IMAPISession, você pode usar um ponteiro para um objeto desse tipo em MAPILogonEx, mas você deve CAST-lo para o tipo IMAPISession.

    hr = MAPILogonEx(0, NULL, NULL, 0, (LPMAPISESSION *)&pSession);
    

Example

O seguinte demonstra como iniciar uma sessão MAPI exemplo de código.

Observação

Para tornar o exemplo de código mais fácil para ler, verificação de segurança e manipulação de erro não estão incluídos.This code example should not be used in a release configuration unless it has been modified to include them.

HRESULT hr;

ICEMAPISession * pSession = NULL;

hr = MAPIInitialize(NULL);

hr = MAPILogonEx(0, NULL, NULL, 0, (LPMAPISESSION *)&pSession);

O Windows Mobile 6 Professional SDK , deste Microsoft Web sitee Windows Mobile 6 Standard SDK, deste Microsoft Web site, enviar com um chamado amostra de código "enviar uma mensagem " que usa a CEMAPI API. For more information, see Sending a Message.

Compiling the Code

To compile the code sample, you must add references to the CE MAPI type library and the CE MAPI header files, to your project.

  1. Add preprocessor directives that include the header files in with the rest of your project files when you build your project. You do this by typing the following statements at the top of either your main C++ source file or your header file.

    #include <cemapi.h>
    #include <mapidefs.h>
    #include <mapiutil.h>
    #include <mapix.h>
    
  2. Specify a linker dependency to the CE MAPI type library as a project property.

    1. Press Alt+F7e o Project Property Pages dialog box appears.
    2. In the dialog box, navigate to the Input property page for the Linker (navigate to Configuration Properties > Linker > Input).
    3. In Additional Dependencies, tipo Cemapi.lib e em seguida, clique OK.
  3. Rebuild the Solution (press Ctrl+Alt+F7).

See Also

Tasks

Connecting to a Message Store
Creating a Message
Sending a Message
Ending a MAPI Session

Concepts

Messaging Samples

Other Resources

Messaging Common Tasks
Messaging Application Development
Messaging