2013-02-26 32 views
5

Tôi đã cố gắng sử dụng các thuộc tính mở rộng trong các cuộc hẹn với EWS, nhưng dường như tôi không thể tìm thấy các cuộc hẹn lại. Phần sở hữu bộ là tương đương với một thể hiện trong câu hỏi này:API quản lý dịch vụ Web Exchange - Tìm các mục theo thuộc tính mở rộng

How to Update an Appointment from Exchange Web Service Managed API 2.0 in ASP.NET

Khi tôi cố gắng để lấy hẹn, tôi đã theo các ví dụ:

http://msdn.microsoft.com/en-us/uc14trainingcourse_5l_topic3#_Toc254008129 http://msdn.microsoft.com/en-us/library/exchange/dd633697(v=exchg.80).aspx

Nhưng tôi không bao giờ nhận được bất kỳ cuộc hẹn nào được trả lại khi tôi thực hiện tra cứu.

Đây là mã cho việc tra cứu:

 ItemView view = new ItemView(10); 

     // Get the GUID for the property set. 
     Guid MyPropertySetId = new Guid("{" + cGuid + "}"); 

     // Create a definition for the extended property. 
     ExtendedPropertyDefinition extendedPropertyDefinition = 
      new ExtendedPropertyDefinition(MyPropertySetId, "AppointmentID", MapiPropertyType.String); 

     view.PropertySet = 
     new PropertySet(
       BasePropertySet.IdOnly, 
       ItemSchema.Subject, 
       AppointmentSchema.Start, 
       AppointmentSchema.End, extendedPropertyDefinition); 

     SearchFilter filter = new SearchFilter.Exists(extendedPropertyDefinition); 

     FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, filter, 
      view); 

Any help is appreciated rất nhiều.

Edit: Khi tôi cố gắng tạo ra các tài sản như tài liệu cho thấy:

http://msdn.microsoft.com/en-us/library/exchange/dd633654(v=exchg.80).aspx

Nó thất bại vì một im Guid của nó thêm như giá trị tài sản. : -/

Chỉnh sửa lần nữa: Chỉ cần cố gắng nhận được tất cả các cuộc hẹn cho ngày hôm nay, và nhận được tài sản từ việc bổ nhiệm tôi vừa tạo ra, và nó nói giống như tôi được lưu trữ, mà không có {}, vì vậy nó phải được somthing với bộ lọc.

Chỉnh sửa một lần nữa * Nó có somthing để làm với

ExtendedPropertyDefinition extendedProperty = new ExtendedPropertyDefinition(

nếu tôi sử dụng:

new ExtendedPropertyDefinition(
       DefaultExtendedPropertySet.Appointment, 
       "AppointmentID", 
       MapiPropertyType.String); 

Nó tìm tất cả các cuộc hẹn với tài sản, nhưng nếu tôi tìm kiếm một cụ thể một:

Guid MyPropertySetId = new Guid("{" + cGuid + "}"); 

ExtendedPropertyDefinition extendedProperty = 
      new ExtendedPropertyDefinition(
       MyPropertySetId, 
       "AppointmentID", 
       MapiPropertyType.String); 

Sau đó, không tìm thấy gì.

Trả lời

20

đây là một samplecode làm thế nào để tạo một cuộc hẹn với CustomID và tìm thấy nó sau khi tiết kiệm:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); 
     service.AutodiscoverUrl("[email protected]"); 

     ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmenId", MapiPropertyType.String); 

     Guid testid = Guid.NewGuid(); 

     Appointment appointment = new Appointment(service); 
     appointment.Subject = "Test"; 
     appointment.Start = DateTime.Now.AddHours(1); 
     appointment.End = DateTime.Now.AddHours(2); 
     appointment.SetExtendedProperty(def, testid.ToString()); 
     appointment.Save(WellKnownFolderName.Calendar); 

     SearchFilter filter = new SearchFilter.IsEqualTo(def, testid.ToString()); 

     FindItemsResults<Item> fir = service.FindItems(WellKnownFolderName.Calendar, filter, new ItemView(10)); 

hy vọng điều này giúp bạn ...

+0

Cảm ơn, bệnh thử này ra. – Jacob

+0

Các tác phẩm dành cho tôi! Cảm ơn rất nhiều! – Jacob

+0

chào mừng bạn ... có thể lần sau bạn có thể giúp tôi;) bạn có thể vui lòng đặt "được trợ giúp";) –

0

Bạn tìm kiếm trong hộp thư đến để biết các cuộc hẹn. Ở đó bạn sẽ không bao giờ tìm thấy chúng. Thay vào đó, hãy thử tìm kiếm trong Lịch.

+0

Vâng, tôi đã tìm kiếm trong thư mục sai , nhưng nó vẫn không tìm thấy gì: -/ – Jacob

+0

hmm ... có lẽ đó là vì cách bạn tạo thuộc tính của bạn. thử mã này: ExtendedPropertyDefinition propdef = new ExtendedPropertyDefinition (Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet.PublicStrings, name, MapiPropertyType.String); để thêm và tìm kiếm. Tôi đã có một số vấn đề bằng cách sử dụng hướng dẫn quá. Điều này dễ dàng hơn và hoạt động perferct trong mã của tôi. –

0

Dưới đây là ví dụ về việc đặt guid làm tài sản mở rộng và nhận cuộc hẹn dựa trên hướng dẫn.

private static readonly PropertyDefinitionBase AppointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmentID", MapiPropertyType.String); 
public static PropertySet PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointementIdPropertyDefinition); 


//Setting the property for the appointment 
public static void SetGuidForAppointement(Appointment appointment) 
{ 
    try 
    { 
     appointment.SetExtendedProperty((ExtendedPropertyDefinition)AppointementIdPropertyDefinition, Guid.NewGuid().ToString()); 
     appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone); 
    } 
    catch (Exception ex) 
    { 
     // logging the exception 
    } 
} 

//Getting the property for the appointment 
public static string GetGuidForAppointement(Appointment appointment) 
{ 
    var result = ""; 
    try 
    { 
     appointment.Load(PropertySet); 
     foreach (var extendedProperty in appointment.ExtendedProperties) 
     { 
      if (extendedProperty.PropertyDefinition.Name == "AppointmentID") 
      { 
       result = extendedProperty.Value.ToString(); 
      } 
     } 
    } 
    catch (Exception ex) 
    { 
    // logging the exception 
    } 
    return result; 
} 
+0

Đây là mã tôi đang sử dụng để cài đặt Hướng dẫn. Phần thứ hai lấy các guid từ một cuộc hẹn. Vấn đề của tôi là tôi cần tìm một cuộc hẹn cụ thể khi chỉ có Guid. – Jacob

+0

tốt, khi bạn tìm thấy các cuộc hẹn từ những ngày nhất định cho những người khác, sau đó bạn áp dụng một trường hợp nếu tìm kiếm trong số họ bằng cách sử dụng Guid mà bạn trích xuất nếu nó phù hợp hay không. – BraveHeart

Các vấn đề liên quan