1

您好我正在尝试以编程方式将 webcal 添加到前景中

Outlook.Application ouApplication = new Outlook.Application();
Outlook.Folder newFolder = ouApplication.GetNamespace("MAPI").OpenSharedFolder("webcalURL") as Outlook.Folder;

但是我如何检查已经添加了相同的 webcal 的位置...

if(!AlreadyAdded())
{
    Outlook.Application ouApplication = new Outlook.Application();
    Outlook.Folder newFolder = ouApplication.GetNamespace("MAPI").OpenSharedFolder("webcalURL") as Outlook.Folder;
}

bool AlreadyAdded()
{
     //Check webcal is already added or not
}
4

1 回答 1

0

一种方法是在您的 : 中使用一个private对象class

private Outlook.Application ouApplication;
if(!AlreadyAdded())
{
   ouApplication = new Outlook.Application();
   Outlook.Folder newFolder = ouApplication.GetNamespace("MAPI").OpenSharedFolder("webcalURL") as Outlook.Folder;
}

bool AlreadyAdded()
{
   return ouApplication!=null;
}

另一种方法是使用singleton类。

在此处查看参考

于 2016-12-15T08:20:38.643 回答