Monday, July 07, 2008

I've got a bit of an overload of "Unread or For Follow Up" items in Outlook at the moment => 149 to be precise. To tackle them I'm setting a "count down" schedule that is to finish by 1 October 2008. Every five days I need to make sure that the count is at or below the target number. I've popped my descending count into Outlook using the following PowerShell script.

$o = new-object -com Outlook.Application
$mapi = $o.GetNamespace("MAPI")
$cal = $mapi.GetDefaultFolder(9) # == olDefaultCalendar

$d1 = [DateTime]"1 oct 2008"
$d0 = get-date
$ticks=$d1.Subtract($d0).Ticks*5/151

$n=150
while ($n -ge 5) {
    $d0=$d0.AddTicks($ticks)
    $n-=5
    $appt = $cal.Items.Add(1) # == olAppointmentItem
    $appt.Start = $d0
    $appt.End = $d0
    $appt.Subject = "({0})" -f $n
    $appt.AllDayEvent = $true
    $appt.ReminderSet = $false
    $appt.Save()
}

posted on Monday, July 07, 2008 10:12:11 PM (Cen. Australia Standard Time, UTC+09:30)  #    Comments [0] Trackback
Related posts:
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):