Compartilhar via


Ending a MAPI Session

Windows Mobile SupportedWindows Embedded CE Not Supported

9/8/2008

Quando os usuários terminar executar tarefas de mensagens, não há necessidade para consumir valiosos recursos sistema com o subsistema de mensagens. No que apontar, ele é uma boa idéia livre recursos por encerrar a sessão MAPI.

Para finalizar a sessão MAPI

  1. Finalizar a sessão MAPI com o método IMAPISession::Logoff, da seguinte maneira:

    hr = pSession->Logoff(0, 0, 0);
    
  2. Diminuir o contagem de referência sessão MAPI por chamado MAPI IUnknown::Release no objeto de sessão MAPI:

    pSession->Release();
    
  3. Diminuir o subsistema contagem de referência MAPI e excluir qualquer por-instância dados globais para o MAPI DLL com a função MAPI MAPIUninitialize global:

    MAPIUninitialize();
    

Example

O seguinte demonstra como encerrar 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);

hr = pSession->Logoff(0, 0, 0);

pSession->Release();
pSession = NULL;

MAPIUninitialize();

Both the Windows Mobile 6 Professional SDK and the Windows Mobile 6 Standard SDK ship with a code sample called Sending E-mail, which you can build and run to gain a better understanding of the fundamental messaging concepts. The default location for the sample:

C:\Program Files\Windows Mobile 6 SDK\Samples\Common\CPP\Win32\SendMail\SendMail.sln

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.

See Also

Tasks

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

Concepts

Messaging Samples

Other Resources

Messaging Common Tasks
Messaging Application Development
Messaging