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
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