Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
# a script to send me a daily outlook calendar summary # # some references: # quick calendar example: # http://www.perlmonks.org/?node_id=201750 # handle recurring appts, sorting, etc.: # http://msdn2.microsoft.com/en-us/library/aa155752(office.10).aspx # create outlook notes: # http://www.perlmonks.org/?node_id=240157 # send outlook mail (trickier than I'd assumed so I used SMTP instead +): # http://www.perlmonks.org/?node_id=185757 use strict; BEGIN {$main::TZ = 'US/Eastern';}; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Outlook'; use Win32::OLE::Variant; use Date::Manip; my $OL = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application', 'Quit'); my $NameSpace = $OL->GetNameSpace("MAPI"); my $cal = $NameSpace->GetDefaultFolder(olFolderCalendar) or die("error + getting cal folder: " . Win32::OLE->LastError()); my $todayDT = ParseDate("today 00:00:00"); my $today = justDate($todayDT); my $todayRange = qq{[Start] >= '$today' and [Start] < '$today 11:59 pm +'}; my $tomorrow = justDate(Date_NextWorkDay($todayDT, 1)); my $tomorrowRange = qq{[Start] >= '$tomorrow' and [Start] < '$tomorrow + 11:59 pm'}; my $body; for my $range (['TODAY', $todayRange, $today], ['TOMORROW', $tomorrowRange, $tomorrow], ) { $body .= sprintf("\n%s %s [%s]\n\n", DayOfWeek($range->[2]), $rang +e->[2], $range->[0]); my $appts = $cal->Items() or die("error getting cal appts: " . Win +32::OLE->LastError()); $appts->Sort("[Start]"); $appts->{IncludeRecurrences} = 'True'; $appts = $appts->Restrict($range->[1]); for my $appt (in $appts) { $body .= sprintf("%s %s\n", justTime($appt->{Start}), $appt->{Subject}); } } my $mail = q{From: "Joe" <joe@example.com> To: "Joe" <joe@example.com> Subject: calendar for today }; $mail .= "\n$body"; print $mail; print "sending mail...\n"; use Net::SMTP; my $smtp = Net::SMTP->new('mail.example.com', Debug => 1); $smtp->mail('joe@example.com'); $smtp->to('joe@example.com'); $smtp->data(); $smtp->datasend($mail); $smtp->dataend(); $smtp->quit; # for outlook date format: sub justTime { my (undef, $time, $ampm) = split(/\s/, $_[0], 3); $time = substr($time, 0, -3); # chop off seconds $time =~ s{^ (\d) :}{ $1:}x; return join(' ', $time, $ampm); } # for datemanip date format: sub DayOfWeek { my ($y, $m, $d) = splitDate($_[0]); return [qw(Sun Mon Tue Wed Thu Fri Sat)]->[Date_DayOfWeek($m, $d, +$y)]; } # for datemanip date format: sub justDate { join('-', splitDate($_[0])); } # for datemanip date format: sub splitDate { return (substr($_[0], 0, 4), substr($_[0], 4, 2), substr($_[0], 6, 2)); }

In reply to read MS Outlook Calendar by blahblahblah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (4)
    As of 2015-07-04 00:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (57 votes), past polls