2016-08-14 1 views
0

버튼 클릭으로 웹 응용 프로그램에서 실행하려는 Outlook 연락처 조회가 있습니다. 다음 코드는 내 DLL 클래스 및 방법 :Outlook 웹 페이지 연락처 가져 오기 - 0x800a139e - JavaScript 런타임 오류

public class AddressLookup 
{ 
    public Contact getContact() 
    { 
     RDOSession session = new RDOSession(); 
     session.Logon(Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing); 
     bool loggedOn = session.LoggedOn; 

     try 
     { 
      RDOAddressBook rAddressBook = session.AddressBook; 
      RDORecipients rContacts = rAddressBook.ShowAddressBook(Title: "Outlook Lookup", OneAddress: true); 

      RDORecipient rContact = rContacts.GetFirst(); 
      RDOAddressEntry aeContact = rContact.AddressEntry; 

      return new Contact(aeContact.Name, aeContact.JobTitle, aeContact.CompanyName, aeContact.StreetAddress); 
     } 
     catch (Exception) 
     { 
      return new Contact("", "", "", ""); 

     }    
    } 

내가 버튼을 웹 응용 프로그램에 클릭하면 실행할 때 다음 코드는 다음과 같습니다

protected void btnBillHeaderDetailsOutlook_Click(object sender, EventArgs e) 
{ 
    AddressLookup al = new AddressLookup();  

    var contact = al.getContact(); 
} 

열 때 VS 처음으로, 전체 프로세스가 예상대로 실행되고 contact 변수가 올바른 데이터를 반환합니다. 이 문제는 버튼을 다시 클릭하거나 전체 웹 앱을 다시 실행하려고 시도 할 때 발생합니다.

Unhandled exception at line 885, column 13 in http://localhost:27855/ScriptResource.axd?d= ... 0x800a139e - JavaScript runtime error: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.

내가 아직이 작업을 수행하지 못했기 때문에 뭔가 기본적인 것을 놓친 것처럼 느껴집니다. 많은 도움에 감사드립니다. (즉, 도움이된다면)

+0

Outlook은 C 또는 C++로 작성되었으므로 (afaik는 Office/Office System/InfoPath) 완전히 명시 적으로 필요하거나 더 쉽게 감싸는 데 필요한 리소스가있는 관리되지 않는 라이브러리로 작업하고 있습니다. using 문에서 try ... using (RDOSession session .... using (RDOAddressBook rAddressBook ...)을 사용하십시오.) { –

+0

@JeremyThompson 감사합니다, RDOSession 개체에 사용할 수있는 dispose() 메서드가 없으므로이 개체가 IDisposable을 구현하지 않는 것으로 보입니다. –

답변

0

난 당신이 로컬 호스트 그러나 당신은 서버 쪽 컨텍스트에서 것을 사무 자동화을하고 나타납니다이를 실행하고 알 예상대로 나는 윈도우 응용 프로그램으로 실행

는 부하이다 기술 자료 문서 : Considerations for server-side Automation of Office에 따라 지원되지 않습니다. 이것은 winform 응용 프로그램을 사용하여 정상적으로 작동하는 이유를 설명합니다.

서버에 Office를 설치하려고하지 않으셨습니까? 대신 연락처 가져 오기와 같은 서버 측 자동화 구현을 위해 Exchange Servers WebService를 사용해야합니다.

편집 :

"That fact has just dawned on me. This web app is for a intranet system and the dll will be registered on all the users PC's. To be able to use the users office installation with this dll would I need to run it through javascript somehow? Thanks"

자바 스크립트 방법 : 그 사용자가 어떤 웹 브라우저를 사용할 수 있습니다로

는 개인적으로 내가 the orthodox method and use the web service을 가고 싶어은 IE는 액티브 X 지원하는 유일한 하나입니다. 또한 IE에서 작동 시키려면 ActiveX 권한 (SysAdmin이 무시하거나 잠길 수 있음)을 사용해야 할 수도 있습니다. 당신은 자바 스크립트를 통해 수행하려는 경우에 도움이 될 것입니다이 코드가 작동하지 않는 경우

var Const_olFolderContacts = 10; 
var objApp = new ActiveXObject(“Outlook.Application”); 
var objNS = objApp.GetNamespace(“MAPI”); 
var colContacts = objNS.GetDefaultFolder(Const_olFolderContacts).Items 
for(var i=1; i<=colContacts.count;i++) 
{ 
var v = colContacts.item(i); 
alert(v[“FullName”]+” (“+v[“Email1Address”]+”)”); 
} 

", 다음을 수행하십시오 Internet Explorer에서 을 도구로 이동 | 인터넷 옵션 | 보안 -> '사용자 정의에서 레벨 초기화 '로 이동'및 스크립트 액티브 스크립트 사용에 안전 표시 '선택'확인 여부를 제어 "-이 지금 작동합니다"

Wordpress blog ref.

Stackoverflow ref.

Exchange 웹 서비스 방법 :

public class MicrosoftOutlook 
{ 
    private ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); 
    public MicrosoftOutlook() 
    { 
     try 
     { 
      service.Url = new Uri("https://webmail.YourCompanyName.com.au/EWS/Exchange.asmx"); 

      service.UseDefaultCredentials = true; 

     } catch (System.Runtime.InteropServices.COMException ex) 
     { 
     } 
    } 

    public void ListContacts() { 
    // Get the number of items in the contacts folder. To limit the size of the response, request only the TotalCount property. 
    ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts, new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount)); 

    // Set the number of items to the number of items in the Contacts folder or 50, whichever is smaller. 
    int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50; 

    // Instantiate the item view with the number of items to retrieve from the Contacts folder. 
    ItemView view = new ItemView(numItems); 

    // To keep the response smaller, request only the display name. 
    view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName); 

    // Request the items in the Contacts folder that have the properties that you selected. 
    FindItemsResults<Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view); 

    // Display the list of contacts. (Note that there can be a large number of contacts in the Contacts folder.) 
     foreach (Item item in contactItems) 
     { 
      if (item is Contact) 
      { 
       Contact contact = item as Contact; 
       Console.WriteLine(contact.DisplayName); 
      } 
     } 
    } 
} 

참조 내 코드이 MSDN ref.

+0

감사합니다. 그 사실은 지금 막 나에게 떠올랐다. 이 웹 응용 프로그램은 인트라넷 시스템 용이며 dll은 모든 사용자 PC에 등록됩니다. 이 dll을 사용하여 사용자 사무실 설치를 사용할 수 있으려면 어떻게 든 javascript를 통해 실행해야합니까? 감사 –