using System;
using System.Collections;
using System.Diagnostics;
using Microsoft.Office.Interop.Outlook;
namespace RemoveOutlookCalendarDuplicates
{
class MainClass
{
[STAThread]
static void Main(string[] args)
{
Application olApp = new ApplicationClass();
NameSpace outlookNS =
olApp.GetNamespace("MAPI");
MAPIFolder calendarFolder =
outlookNS.GetDefaultFolder(
OlDefaultFolders.olFolderCalendar);
while(true)
{
bool somethingDeleted = false;
Hashtable uniqueItems = new Hashtable();
foreach(AppointmentItem oi in calendarFolder.Items)
{
string uniqueKey =
String.Format("{0} {1} {2:yyyyMMddhhmmss} {3:yyyyMMddhhmmss}",
oi.Subject, oi.Location, oi.Start, oi.End);
if(uniqueItems.ContainsKey(uniqueKey))
{
Console.WriteLine("DELETED: " + uniqueKey);
oi.Delete();
somethingDeleted = true;
}
else
{
uniqueItems.Add(uniqueKey, String.Empty);
}
}
if(!somethingDeleted) break;
}
Console.WriteLine("** PRESS RETURN **");
Console.ReadLine();
}
}
}
Nenhum comentário:
Postar um comentário