Every time you use MAPI, you must log on before doing anything else. Logging on returns to you a Session Handle, which is merely a number which you use as a parameter to other MAPI functions. After you are finished with MAPI, you log off to free up any resources used by the session.
The general form is as follows:
Result = MAPILogon(<various parameters>, Session) <other MAPI calls> Result = MAPILogoff(Session, <various parameters>)