2016-10-11 11 views
0

다음은 ASP.NET 웹 사이트의 페이지 뒤쪽에있는 C# 코드입니다. 이 코드는 버튼 클릭시 실행되며 컴퓨터에서 디버깅 할 때 페이지의 div로 가져 오는 데 필요한 것을 다시 가져옵니다. 나는 이것은 Web.config의C# ASP.NET 웹 페이지에서 Outlook 공용 폴더 항목을 읽으려고 시도합니다.

입니다

In order to access a public folder, the effective caller must have a mailbox. 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: > Microsoft.Exchange.WebServices.Data.ServiceResponseException: In order to access a public folder, the effective caller must have a mailbox.

Source Error: Line 47: Folder myPublicFoldersRoot = Folder.Bind(exchangeService, WellKnownFolderName.PublicFoldersRoot);

말 영문 페이지가로드 있지만, 때 'btnVctn'버튼이 오류 밖으로 클릭, 생산 IIS 서버에 사이트를 구축

protected void btnVctn_Click(object sender, EventArgs e) 
{ 
    Label1.Visible = true; 
    btnCloseVactn.Visible = true; 
    ExchangeService exchangeService = new ExchangeService(); 
    exchangeService.Url = new Uri("https://mymailserviceurl/ews/exchange.asmx"); 


    Folder myPublicFoldersRoot = Folder.Bind(exchangeService, WellKnownFolderName.PublicFoldersRoot); 
    string myPublicFolderPath = @"IT Services\ITServicesOutofOfficeCalendar"; 
    string[] folderPath = myPublicFolderPath.Split('\\'); 
    FolderId fId = myPublicFoldersRoot.Id; 
    foreach (string subFolderName in folderPath) 
    { 
     fId = FindPublicFolder(exchangeService, fId, subFolderName); 
     if (fId == null) 
     { 
      Label1.Text = "ERROR: Can't find public folder {0} " + myPublicFolderPath; 

     } 
    } 

    Folder folderFound = Folder.Bind(exchangeService, fId); 
    if (String.Compare(folderFound.FolderClass, "IPF.Appointment", StringComparison.Ordinal) != 0) 
    { 
     Label1.Text = "ERROR: Public folder {0} is not a Calendar " + myPublicFolderPath; 

    } 

    CalendarFolder AK_Calendar = CalendarFolder.Bind(exchangeService, fId, BasePropertySet.FirstClassProperties); 

    FindItemsResults<Appointment> AK_appointments = AK_Calendar.FindAppointments(new CalendarView(DateTime.Now, DateTime.Now.AddDays(10))); 


    string rString = string.Empty; 


    foreach (Appointment AK_appoint in AK_appointments) 
    { 

     rString += AK_appoint.Subject + "<br/> Start Date: " + AK_appoint.Start + "<br/>End Date: " + AK_appoint.End + "<br/>"; 
    } 

    Label1.Text = rString; 

    ClientScript.RegisterStartupScript(this.GetType(), "hash", "location.hash = '#dvWorkQueue';", true); 
} 


public static FolderId FindPublicFolder(ExchangeService myService, FolderId baseFolderId,string folderName) 
{ 

    FolderView folderView = new FolderView(100, 0); 
    folderView.OffsetBasePoint = OffsetBasePoint.Beginning; 
    folderView.PropertySet = new PropertySet(FolderSchema.DisplayName, FolderSchema.Id); 

    FindFoldersResults folderResults; 
    do 
    { 
     folderResults = myService.FindFolders(baseFolderId, folderView); 

     foreach (Folder folder in folderResults) 
      if (String.Compare(folder.DisplayName, folderName, StringComparison.OrdinalIgnoreCase) == 0) 
       return folder.Id; 

     if (folderResults.NextPageOffset.HasValue) 
      folderView.Offset = folderResults.NextPageOffset.Value; 
    } 
    while (folderResults.MoreAvailable); 

    return null; 
} 

누구든지 문제를 해결할 수있는 방법을 밝힐 수 있습니까? TIA

답변

0

아마도 로컬 시스템에 Outlook이 설치 및 구성되어있을 수 있습니다. 서버에 배포 할 때 Outlook이 설치되어 있지 않은 것 같습니다.