win form 中可行的COM 组件为什么移到web form 就不行了呢?高手指点

johnlenfu 2003-12-22 08:34:25

Imports System.Reflection
Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form 設計工具產生的程式碼 "

'此為 Web Form 設計工具所需的呼叫。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

'注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
'請勿刪除或移動它。
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此為 Web Form 設計工具所需的方法呼叫
'請勿使用程式碼編輯器進行修改。
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在這裡放置使用者程式碼以初始化網頁
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oApp As Outlook.Application
oApp = Server.CreateObject("Outlook.Application")

' Get Mapi NameSpace and Logon.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon("YourValidProfile", Missing.Value, False, True) ' TODO:

' Create an AppointmentItem.
Dim oAppt As Outlook._AppointmentItem = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)
'oAppt.Display(true) 'Modal

' Change AppointmentItem to a Meeting.
oAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting

' Set some common properties.
oAppt.Subject = "Meeting Request Test"
oAppt.Body = "Hello World"
oAppt.Location = "B503"

oAppt.Start = Convert.ToDateTime("12/22/2003 9:00:00 AM")
oAppt.End = Convert.ToDateTime("12/22/2003 1:00:00 PM")

oAppt.ReminderSet = True
oAppt.ReminderMinutesBeforeStart = 5
oAppt.BusyStatus = Outlook.OlBusyStatus.olBusy ' olBusy
oAppt.IsOnlineMeeting = False
oAppt.AllDayEvent = False

' Add attendees.
Dim oRecipts As Outlook.Recipients = oAppt.Recipients

' Add required attendee.
Dim oRecipt As Outlook.Recipient
oRecipt = oRecipts.Add("johnlenfu") ' TODO:
oRecipt.Type = Outlook.OlMeetingRecipientType.olRequired

' Add optional attendee.
oRecipt = oRecipts.Add("windyxiao") ' TODO:
oRecipt.Type = Outlook.OlMeetingRecipientType.olOptional

oRecipts.ResolveAll()

'oAppt.Display(true)

' Send out request.
oAppt.Send()

' Logoff.
oNS.Logoff()

' Clean up.
oApp = Nothing
oNS = Nothing
oAppt = Nothing
oRecipts = Nothing
oRecipt = Nothing
End Sub
End Class


一下是在asp.net中发送outlook 会议邀请的一段代码,该代码在win form 中运行正常,可到了web form 中出错如下


'/appointment1' 應用程式中發生伺服器錯誤。
--------------------------------------------------------------------------------

存取被拒。
描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。

例外詳細資訊: System.UnauthorizedAccessException: 存取被拒。

沒有授權 ASP.NET 存取要求的資源。請考慮將資源存取權授予 ASP.NET 要求識別。ASP.NET 有一個基本處理序識別 (通常在 IIS 5 上為 {MACHINE}\ASPNET,在 IIS 6 上為 Network Service),會在應用程式未模擬的情況下使用。如果應用程式是透過 <identity impersonate="true"/> 模擬,這個識別將會是匿名使用者 (通常為 IUSR_MACHINENAME) 或經過驗證的要求使用者。

若要取得 ASP.NET 寫入檔案的存取權限,請在檔案總管中以右鍵按一下檔案,選擇 [內容] 並選取 [安全] 索引標籤。按一下 [新增] 加入適當的使用者或群組。反白顯示 ASP.NET 帳戶,並且選取所需存取權限的核取方塊。

原始程式錯誤:


行 29: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
行 30:
行 31: Dim oApp As Outlook.Application = New Outlook.Application
行 32: ' Get Mapi NameSpace and Logon.
行 33: Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")


原始程式檔: c:\inetpub\wwwroot\appointment1\WebForm1.aspx.vb 行: 31


win form 中玩的好好的程序,为什么到了win form 中就不好玩了呢?
...全文
29 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Johnlen 2004-01-02
  • 打赏
  • 举报
回复
up
johnlenfu 2003-12-23
  • 打赏
  • 举报
回复
各位看到的老大帮帮忙啦,
早点搞定好跟老板提过年回家请假的事儿
johnlenfu 2003-12-23
  • 打赏
  • 举报
回复
难道真的没有人会吗?
johnlenfu 2003-12-22
  • 打赏
  • 举报
回复
这个帖子要先结了,进来领分
在web页中发送outlook的会议邀请

http://expert.csdn.net/Expert/topic/2573/2573710.xml?temp=.4487268

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧