473,320 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MAPI Logon fails (NT Service)

Hi All,

I'm having problems with ex MAPI when its running from an NT service.

This is the code i'm running in the log on process.

Please... if you can see ANY problem, let me know....

void Logon(System::String* profile)

{

HRESULT hRes = -1;

LPVOID pMapiInit;

LPTSTR pprof;

FLAGS ntServiceMAPIField = MAPI_NT_SERVICE;

FLAGS mapiInitField = MAPI_NO_COINIT | MAPI_MULTITHREAD_NOTIFICATIONS;

FLAGS mapiLogonFlags = MAPI_NEW_SESSION | MAPI_NO_MAIL | MAPI_EXTENDED |
MAPI_EXPLICIT_PROFILE ;//| MAPI_PASSWORD_UI;

////////////////////////////////////////////////////////

// ***Important: Only if this module is a Service unmark the next 2 line.

mapiInitField |= ntServiceMAPIField;

mapiLogonFlags |= ntServiceMAPIField;

////////////////////////////////////////////////////////
MAPIINIT_0 MAPIINIT = { MAPI_INIT_VERSION, mapiInitField};

pMapiInit = &MAPIINIT;

if (FAILED(hRes = MAPIInitialize(pMapiInit)))

{

Marshal::ThrowExceptionForHR(hRes);

}

pprof = (char*)Marshal::StringToHGlobalAnsi(profile).ToPoi nter();

LPMAPISESSION __pin* pses = &m_pSes;

if (FAILED(hRes = MAPILogonEx((ULONG)0, pprof, NULL, mapiLogonFlags, pses)))

{

Marshal::FreeHGlobal(pprof);

Marshal::ThrowExceptionForHR(hRes);

}

m_pDefMsgStore = NULL;

Marshal::FreeHGlobal(pprof);

}

Regards,

Asaf
Nov 16 '05 #1
1 3384
Michael,

What account is the service running under? By default, I believe that
the account runs over the LOCALSYSTEM (or LOCALSERVICE, I can't remember the
name) account. This account doesn't have access to the netowkr, so you
would have to have the service run under an account which does have access
to the network.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael Zino" <mv****@mercury.co.il.RemoveMe> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi All,

I'm having problems with ex MAPI when its running from an NT service.

This is the code i'm running in the log on process.

Please... if you can see ANY problem, let me know....

void Logon(System::String* profile)

{

HRESULT hRes = -1;

LPVOID pMapiInit;

LPTSTR pprof;

FLAGS ntServiceMAPIField = MAPI_NT_SERVICE;

FLAGS mapiInitField = MAPI_NO_COINIT | MAPI_MULTITHREAD_NOTIFICATIONS;

FLAGS mapiLogonFlags = MAPI_NEW_SESSION | MAPI_NO_MAIL | MAPI_EXTENDED |
MAPI_EXPLICIT_PROFILE ;//| MAPI_PASSWORD_UI;

////////////////////////////////////////////////////////

// ***Important: Only if this module is a Service unmark the next 2 line.

mapiInitField |= ntServiceMAPIField;

mapiLogonFlags |= ntServiceMAPIField;

////////////////////////////////////////////////////////
MAPIINIT_0 MAPIINIT = { MAPI_INIT_VERSION, mapiInitField};

pMapiInit = &MAPIINIT;

if (FAILED(hRes = MAPIInitialize(pMapiInit)))

{

Marshal::ThrowExceptionForHR(hRes);

}

pprof = (char*)Marshal::StringToHGlobalAnsi(profile).ToPoi nter();

LPMAPISESSION __pin* pses = &m_pSes;

if (FAILED(hRes = MAPILogonEx((ULONG)0, pprof, NULL, mapiLogonFlags, pses)))
{

Marshal::FreeHGlobal(pprof);

Marshal::ThrowExceptionForHR(hRes);

}

m_pDefMsgStore = NULL;

Marshal::FreeHGlobal(pprof);

}

Regards,

Asaf

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Suganthi | last post by:
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...
0
by: Mukesh Kumar | last post by:
hi all, I have created some independent reports through crystal reports developer edition v 10 and developed a small tool in .net framework v 1.1 to view these reports through the crystal reports...
0
by: Peter Steele | last post by:
I want to create a local admin account programmatically and set it so that it to have "Logon as Service" rights and not be able to be logged on interactively. How are these extended rights...
0
by: web1110 | last post by:
Hi y'all, I there a way for a service to be notified when a user logs on. Also, is there a way to initiate a system service so it will be the last service to run. Thanx, Bill
0
by: Sid | last post by:
hi all, i'm using mapi in my application and create a mapi session using MAPILogonEx passing it the profile name (that is created dynamically by my program). Now from a windows NT/2k machine when i...
0
by: PhilHip | last post by:
I've written a Windows service in VB.Net that accesses the global address list to obtain all the entries to store them in a local database. The GAL is accessed using the MS Exchange profile on the...
9
by: Tim Baley | last post by:
I recently created some intranet web sevices to expose stored procedures on our SQL Servers (SQL2k). The stored procedures include an audit trail with user/login identification, so the web...
6
by: Manuel | last post by:
Hi, Using the PIA "Microsoft Outlook 11 Object Library". I've noticed that the Logon method of the NameSpace Object is simply ignored. My Outlook 2003 is full updated. For example if I...
1
by: WayneClements | last post by:
Does anyone know why a simple select like : SELECT SettingValue FROM sysCONFIG_SETTINGS WHERE ModuleName = N'ScheduledTask' AND SettingKey = N'Logon' should fail in oracle 10g It fails with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.