I have made use of simple MAPI, and have all of these features working. Unfortunately, I am experiencing two issues. When I provide a profile name and password to the login, the currently logged in profile is still being accessed. The second issue I am having is that whenever I access the Exchange Server, I am given an access warning.
Does anyone know how to log in using a different profile than the person currently logged in, and how to stop the warning messages? My login code is below:
public bool Logon()
{
if (!isLoggedIn)
{
if (String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password))
{
error = MAPILogon(WinHandle, null, null, 0, 0, ref session);
Logging.Log("Logged in using credentials for the current user.");
}
else
error = MAPILogon(WinHandle, username, password, 0, 0, ref session);
if (error != 0)
error = MAPILogon(WinHandle, null, null, MapiLogonUI, 0, ref session);
if (error != 0)
Logging.Log("There was a problem logging in: " + GetLastErrorCode());
else
isLoggedIn = true;
}
return error == 0;
}
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi)]
private static extern int MAPILogon(IntPtr hwnd, string profileName, string password,
int flag, int rsv, ref IntPtr session);
Any assistance would be greatly appreciated. Thank you.

New Topic/Question
Reply



MultiQuote









|