3

フォーム領域を IPM.Appointment メッセージ クラスに追加する Outlook アドインに取り組んでいます。この領域が表示されると、最初にいくつかのプロパティが AppointmentItem に追加されます。

Outlook.AppointmentItem appItem;

private void FormRegion_FormRegionShowing(object sender, System.EventArgs e)
{
    try
    {
        appItem = (Outlook.AppointmentItem)this.OutlookItem;

        appItem.ItemProperties.Add("CustomProperty", Outlook.OlUserPropertyType.olText);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

これは自分のカレンダーでは正常に機能しますが、編集者または所有者のアクセス権を持つ代理カレンダーでアドインを使用しようとすると、次の例外がスローされます。

System.UnauthorizedAccessException: You don't have appropriate permission to perform this operation.
  at Microsoft.Office.Interop.Outlook.Itemproperties.Add(String Name, OlUserPropertType Type, ObjectAddToFolderFields, Object DisplayFormat)
  at ThisAddin.FormRegion.FormRegion_FormRegionShowing(Ovject sender,EventArgs e)

どんな助けでも大歓迎です!

4

1 に答える 1

4

UserProperties で同じ問題が発生しました。私にとっては、プロパティを初めて追加しようとしたときにのみ例外が発生します。そのため、この問題を回避するために、例外をキャッチして再試行します。

Outlook.UserProperties properties = appointmentItem.UserProperties;
Outlook.UserProperty property = null;
try
{
    property = properties.Add(propertyName, Outlook.OlUserPropertyType.olText);
}
catch (System.UnauthorizedAccessException exception)
{
    // the first time didn't work, try again once before giving up
    property = properties.Add(propertyName, Outlook.OlUserPropertyType.olText);
}
于 2014-10-21T13:34:35.270 に答える