在我们的网络应用程序中,我们的客户使用附加.msg(outlook email)作为参考。
我要做的是在.aspx页面中显示.msg文件的html主体
下面的代码在VS 2010 IDE中运行良好,但是当我在同一台机器上部署时,我得到了以下错误,
请帮帮我
Public Shared Function GetMessageHTML(ByVal MsgPath As String) As String
Dim app As Microsoft.Office.Interop.Outlook.Application = Nothing
Dim session As Microsoft.Office.Interop.Outlook.NameSpace = Nothing
Dim mail As Microsoft.Office.Interop.Outlook.MailItem = Nothing
Dim HtmlBody As String = String.Empty
Dim NewHTMLBody As String = String.Empty
Try
app = New Microsoft.Office.Interop.Outlook.Application()
session = app.Session
mail = DirectCast(session.OpenSharedItem(MsgPath.Trim()), Microsoft.Office.Interop.Outlook.MailItem)
HtmlBody = mail.HTMLBody
TryCast(mail, Microsoft.Office.Interop.Outlook._MailItem).Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard)
TryCast(app, Microsoft.Office.Interop.Outlook._Application).Quit()
Try
My.Computer.FileSystem.WriteAllText(HtmlFName, NewHTMLBody, False)
Catch ex As Exception
Return "File Write Exception " & ex.Message
End Try
Catch ex As System.Exception
Return "Read Exception " & ex.Message
Finally
If mail IsNot Nothing Then
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(mail)
End If
If session IsNot Nothing Then
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(session)
End If
If app IsNot Nothing Then
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(app)
End If
End Try
Return HtmlFName
End Function
上面代码读取.msg文件并将html正文内容保存到新的.html文件然后我在IFrame中显示新的html。
我在VS 2010中使用Windows 7,它在开发环境中运行良好但是当我在localhost(同一台机器)上发布时,我收到以下错误
任何人都可以指导我如何解决这个问题吗?我已将物理文件夹的完全权限授予用户IIS_IUSRS