想利用一下Outlook的发邮件功能,但是报错,哪位高人能帮忙分析一下吗?...
...
using Microsoft.Office.Interop.Outlook;
namespace MailTest
{
public class WebForm1 : System.Web.UI.Page
{
                  ......
                  ......
                  ......

private void btnSend_Click(object sender, System.EventArgs e)
{
// ApplicationClass outLookApp = new ApplicationClass();
// MailItemClass mailTask = (MailItemClass)outLookApp.CreateItem(OlItemType.olMailItem); Application outLookApp = new Application();
MailItem mailTask = (MailItem)outLookApp.CreateItem(OlItemType.olMailItem);
mailTask.To = "[email protected]";
mailTask.Subject = "test";
mailTask.Body = "test!";
mailTask.Send();
}
}
}
报错如下:
Access is denied. 
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.UnauthorizedAccessException: Access is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.Source Error: 
Line 57: // MailItemClass mailTask = (MailItemClass)outLookApp.CreateItem(OlItemType.olMailItem);
Line 58: 
Line 59:  Application outLookApp = new Application();
Line 60:  MailItem mailTask = (MailItem)outLookApp.CreateItem(OlItemType.olMailItem);好像是Outlook拒绝访问,不知道为什么,哪位能帮忙看看,谢谢。