1

hi I am trying to add webcal programmatically into the outlook

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

but how can I check where the same webcal is already added...

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
}
Ankur Tripathi
  • 671
  • 9
  • 35

1 Answers1

0

One method is to use a private object in your 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;
}

Another method is to use a singleton class.

View reference here.

Community
  • 1
  • 1
Mihai Alexandru-Ionut
  • 47,092
  • 13
  • 101
  • 128