在我的辅助展望日历中创建约会(Ews托管API)

时间:2017-03-29 12:14:23

标签: c# asp.net-mvc-4 outlook exchangewebservices

我有一个主要的展望日历和一个名为"测试"的辅助展望日历。

我可以在主日历中创建约会。如何创建协议而不是名为test的辅助日历?

    ExchangeService service = new ExchangeService();

   service.Credentials = new WebCredentials("xxxx", "paswordxx");

    service.AutodiscoverUrl("xxxx", RedirectionUrlValidationCallback);


    Appointment appointment = new Appointment(service);

    appointment.Subject = "Exchange Webservice - Opret en appointment";
    appointment.Body = "En appointment oprettes og sættes til 'Busy'";
    appointment.Start = new DateTime(2017, 3, 29, 9, 15, 0);
    appointment.LegacyFreeBusyStatus = LegacyFreeBusyStatus.OOF;
    appointment.End = appointment.Start.AddHours(2);
    appointment.Save(SendInvitationsMode.SendToNone);

1 个答案:

答案 0 :(得分:0)

您可以这样做,首先获取如下所示的测试文件夹ID,然后使用文件夹ID保存。

_globalService参数是ExchangeService对象,可以作为参数传递给GetFolder()或用作全局变量。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@android:color/holo_orange_dark"
  android:orientation="horizontal">

  <ImageView
    android:id="@+id/group_chat_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:src="@mipmap/ic_launcher" />

  <TextView
    android:id="@+id/group_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/group_chat_photo"
    tools:text="Some title" />

  <TextView
    android:id="@+id/num_of_group_users"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/group_name"
    android:layout_toRightOf="@+id/group_members_presence"
    tools:text="10 users" />

  <TextView
    android:id="@+id/group_members_presence"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/group_name"
    android:layout_toRightOf="@+id/group_chat_photo"
    tools:text="Presence" />

  <ImageView
    android:id="@+id/group_chat_options"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:src="@mipmap/ic_launcher" />

</RelativeLayout>

像这样保存

 private FolderId GetFolder()
    {
      FolderId  _gloableFolderId = null;
        try
        {
            //Find folders
            FolderView view = new FolderView(20);
            view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
            view.PropertySet.Add(FolderSchema.DisplayName);
            view.Traversal = FolderTraversal.Deep;
            FindFoldersResults findFoldersResults = _globalService.FindFolders(WellKnownFolderName.Calendar, view);
            foreach (var folder in findFoldersResults)
            {
                if (folder is Folder)
                {
                    if (folder.DisplayName.ToUpper() == "TEST") 
                    {
                        _gloableFolderId = folder.Id;
                        return _gloableFolderId;
                    }
                }
            }
        }
        catch (Exception ex)
        {
          // Log exception or return main calender
        }

        return _gloableFolderId;
    }