Mapi Logon problem

S

Suganthi

Hi,
I have a specific problem while using MAPI for sending the emails from
my application.

My requirement is as follows.

My application will be running either as a service or a process in a
windows 2000/NT server.

For a given user (who is Windows NT user) in the same Windows 2000
server, I want to get the default MAPI profile and send mails using
that profile details. The NT user details obtained as an user input
can be the locally logged on user or some other user in the same
server.

Is it possible to get the same? If yes, how will I do it.

Currently i have tried the following:

1. With the input information (ie) user name, password and domain,I am
doing a LogonUser with valid credentials to get the access to
ExchangeServer. I obtain the handle to the user session through this
call.

2. With the obtained handle, i load the user profile using
LoadUserProfile and then ImpersonateLoggedOnUser.

3. Then with the obtained user profile i perform a MAPILogonEx to
obtain the MAPI session handle. The MAPILogonEx call succeeds, but the
mapi session handle always remains NULL. Since the mapi session handle
is not valid, SendEmail is failing.

What could be the reason for this failure?

Also it would be very helpful if i can get the sequence of operations
to be performed to achieve my requirement.

Thanks!
 
J

Jack Klein

Hi,
I have a specific problem while using MAPI for sending the emails from
my application.

My requirement is as follows.

My application will be running either as a service or a process in a
windows 2000/NT server.

For a given user (who is Windows NT user) in the same Windows 2000
server, I want to get the default MAPI profile and send mails using
that profile details. The NT user details obtained as an user input
can be the locally logged on user or some other user in the same
server.

Is it possible to get the same? If yes, how will I do it.

Currently i have tried the following:

1. With the input information (ie) user name, password and domain,I am
doing a LogonUser with valid credentials to get the access to
ExchangeServer. I obtain the handle to the user session through this
call.

2. With the obtained handle, i load the user profile using
LoadUserProfile and then ImpersonateLoggedOnUser.

3. Then with the obtained user profile i perform a MAPILogonEx to
obtain the MAPI session handle. The MAPILogonEx call succeeds, but the
mapi session handle always remains NULL. Since the mapi session handle
is not valid, SendEmail is failing.

What could be the reason for this failure?

Also it would be very helpful if i can get the sequence of operations
to be performed to achieve my requirement.

Thanks!

Ask this in one of the Windows programming groups in the
family, or one of Microsoft's
support groups in the family. Your
question has nothing to do with the C++ language itself, the only
topic here. It is entirely about the Windows API.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top