Outlook automation gives COMException Server execution failed

G

Guest

I wrote the following code:
oApp = new Outlook.Application();
oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
//gets defaultfolder for my Outlook Outbox
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);

But it won't work and it is giving me the following error:
Server Error in '/SendEmail' Application
--------------------------------------------------------------------------------

Server execution failed
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Server
execution failed

Source Error:


Line 24: {
Line 25: //Return a reference to the MAPI layer
Line 26: oApp = new Outlook.Application();
Line 27: oApp = new Outlook.Application();
Line 28: oNameSpace= oApp.GetNamespace("MAPI");


Source File: c:\inetpub\wwwroot\sendemail\outlookmail.aspx.cs Line: 26

Stack Trace:


[COMException (0x80080005): Server execution failed]
SendEmail.OutlookMail..ctor() in
c:\inetpub\wwwroot\sendemail\outlookmail.aspx.cs:26
ASP.OutlookMail_aspx..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\sendemail\c53a1a47\a51e0147\tiscp1-q.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context) +164

[HttpException (0x80004005): Failed to create page of type
'ASP.OutlookMail_aspx'.]
System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context) +337
System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
virtualPath, String inputFile, HttpContext context) +43
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String
requestType, String url, String path) +44
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig) +698

System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +173
 
G

Girish bharadwaj

Here is a nice little post
http://groups.google.com/groups?hl=...&selm=%23B88VD3ACHA.2164%40tkmsftngp04&rnum=4
(watch for wraps) that shows how to setup so that you can use outlook in
ASP.NET

That might help.


Bassel Tabbara said:
I wrote the following code:
oApp = new Outlook.Application();
oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
//gets defaultfolder for my Outlook Outbox
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);

But it won't work and it is giving me the following error:
Server Error in '/SendEmail' Application.
-------------------------------------------------------------------------- ------

Server execution failed
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Server
execution failed

Source Error:


Line 24: {
Line 25: //Return a reference to the MAPI layer
Line 26: oApp = new Outlook.Application();
Line 27: oApp = new Outlook.Application();
Line 28: oNameSpace= oApp.GetNamespace("MAPI");


Source File: c:\inetpub\wwwroot\sendemail\outlookmail.aspx.cs Line: 26

Stack Trace:


[COMException (0x80080005): Server execution failed]
SendEmail.OutlookMail..ctor() in
c:\inetpub\wwwroot\sendemail\outlookmail.aspx.cs:26
ASP.OutlookMail_aspx..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\sendemail\c53a1a47\a51e0147\tiscp1-q.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context) +164

[HttpException (0x80004005): Failed to create page of type
'ASP.OutlookMail_aspx'.]
System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context) +337
System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
virtualPath, String inputFile, HttpContext context) +43
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String
requestType, String url, String path) +44
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig) +698
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep
..Execute() +95
 
G

Guest

Hi Girish,
Thanks for the tip. I was thinking in these terms but I don't like the fact
to use the System account. Can I use a different account who has enough
priviliges to access outlook?

Thanks,

Bassel



Girish bharadwaj said:
Here is a nice little post
http://groups.google.com/groups?hl=...&selm=%23B88VD3ACHA.2164%40tkmsftngp04&rnum=4
(watch for wraps) that shows how to setup so that you can use outlook in
ASP.NET

That might help.


Bassel Tabbara said:
I wrote the following code:
oApp = new Outlook.Application();
oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
//gets defaultfolder for my Outlook Outbox
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);

But it won't work and it is giving me the following error:
Server Error in '/SendEmail' Application.
-------------------------------------------------------------------------- ------

Server execution failed
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Server
execution failed

Source Error:


Line 24: {
Line 25: //Return a reference to the MAPI layer
Line 26: oApp = new Outlook.Application();
Line 27: oApp = new Outlook.Application();
Line 28: oNameSpace= oApp.GetNamespace("MAPI");


Source File: c:\inetpub\wwwroot\sendemail\outlookmail.aspx.cs Line: 26

Stack Trace:


[COMException (0x80080005): Server execution failed]
SendEmail.OutlookMail..ctor() in
c:\inetpub\wwwroot\sendemail\outlookmail.aspx.cs:26
ASP.OutlookMail_aspx..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\sendemail\c53a1a47\a51e0147\tiscp1-q.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context) +164

[HttpException (0x80004005): Failed to create page of type
'ASP.OutlookMail_aspx'.]
System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context) +337
System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
virtualPath, String inputFile, HttpContext context) +43
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String
requestType, String url, String path) +44
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig) +698
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep
..Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +173




-------------------------------------------------------------------------- ------
Version Information: Microsoft .NET Framework Version:1.1.4322.985; ASP.NET
Version:1.1.4322.968
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top