Outlook 2003 and ASP.NET

S

Snig

Hi

I'm into creating a web application in C# (.NET Framework 1.1) which
would list and manage the outlook tasks.

If I try to do this in a Windows Application, it works fine. But there
are many issues in case of Web application.

Code:
Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
Outlook.MAPIFolder tasks =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
Outlook.Items items = tasks.Items;
Outlook.TaskItem item = null;
for (int i=1;i<items.Count; i++)
{
item = (Outlook.TaskItem)items;
ListBox1.Items.Add(item.Subject);
item.Close(Outlook.OlInspectorClose.olDiscard);
item = null;
}

items = null;
tasks = null;
ns = null;
app.Quit();


Case 1: The Anonymous Access is ON and processModel in machine.config
is MACHINE, I get Access Denied error in the 1st line of code.
Case 2: The Anonymous Access is OFF and processModel in machine.config
is MACHINE, I get Access Denied error in the 1st line of code.
Case 3: The Anonymous Access is ON and processModel in machine.config
is SYSTEM, there is no error, but no tasks are displayed. However, I
still sometimes get "Server Execution failed" error.
Case 4: The Anonymous Access is OFF and processModel in machine.config
is SYSTEM, there is no error, but no tasks are displayed. However, I
still sometimes get "Server Execution failed" error.
Case 5: I tried to impersonate current user, user having administrator
permission; but again got Access Denied error.

I know as per Microsoft, Outlook object model is unsuitable to run in
web applications (Q237913)
http://support.microsoft.com/suport/kb/Articles/q237/9/13.asp; but if
we take Case 3/4 why tasks are not being displayed, where as in case 5
I get access denied error !!

And more than that, the last line of code (app.Quite();) is supposed to
close the outlook application, but I can see the outlook.exe still
running in the task manager even after the web application is closed.
It is still there even if I stop the www service !!

I tried to logon in MAPI also,
ns.Logon(Type.Missing, Type.Missing, false, true);
but in vain.

In case of other office applications like Word/Excel etc, we can give
permission to any specific user/role by dcomcnfg.exe, but I'm unable to
find any suitable application for outlook listed in the dcomcnfg list.
So I'm wondering if it is a permission issue, which permission should I
assign to the user?

I can see a number of posts related to this topic in various forums,
but unfortunately none could reach to a decision or final suggestion.


Regards
Snig.
 
K

Kevin Spencer

Hi Snig,

I think you'll find more help on this in the Outlook programming newsgroup:
microsoft.public.office.developer.outlook.vba

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

Snig said:
Hi

I'm into creating a web application in C# (.NET Framework 1.1) which
would list and manage the outlook tasks.

If I try to do this in a Windows Application, it works fine. But there
are many issues in case of Web application.

Code:
Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
Outlook.MAPIFolder tasks =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
Outlook.Items items = tasks.Items;
Outlook.TaskItem item = null;
for (int i=1;i<items.Count; i++)
{
item = (Outlook.TaskItem)items;
ListBox1.Items.Add(item.Subject);
item.Close(Outlook.OlInspectorClose.olDiscard);
item = null;
}

items = null;
tasks = null;
ns = null;
app.Quit();


Case 1: The Anonymous Access is ON and processModel in machine.config
is MACHINE, I get Access Denied error in the 1st line of code.
Case 2: The Anonymous Access is OFF and processModel in machine.config
is MACHINE, I get Access Denied error in the 1st line of code.
Case 3: The Anonymous Access is ON and processModel in machine.config
is SYSTEM, there is no error, but no tasks are displayed. However, I
still sometimes get "Server Execution failed" error.
Case 4: The Anonymous Access is OFF and processModel in machine.config
is SYSTEM, there is no error, but no tasks are displayed. However, I
still sometimes get "Server Execution failed" error.
Case 5: I tried to impersonate current user, user having administrator
permission; but again got Access Denied error.

I know as per Microsoft, Outlook object model is unsuitable to run in
web applications (Q237913)
http://support.microsoft.com/suport/kb/Articles/q237/9/13.asp; but if
we take Case 3/4 why tasks are not being displayed, where as in case 5
I get access denied error !!

And more than that, the last line of code (app.Quite();) is supposed to
close the outlook application, but I can see the outlook.exe still
running in the task manager even after the web application is closed.
It is still there even if I stop the www service !!

I tried to logon in MAPI also,
ns.Logon(Type.Missing, Type.Missing, false, true);
but in vain.

In case of other office applications like Word/Excel etc, we can give
permission to any specific user/role by dcomcnfg.exe, but I'm unable to
find any suitable application for outlook listed in the dcomcnfg list.
So I'm wondering if it is a permission issue, which permission should I
assign to the user?

I can see a number of posts related to this topic in various forums,
but unfortunately none could reach to a decision or final suggestion.


Regards
Snig.
 

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,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top