So I have an old VBS script that access a public folder on MS Exchange, grabs the messages from X minutes ago and looks to see if there are X matches of 3 seperate subjects, then it will send an alert.
I'm converting this to Perl because my VBS way is very clunky and prone to breaking due to the way I have to access the folders. With IMAPClient I can just go directly to the folder I need by name.
I have it working enough to pull out the subject and dates due to the helpful docs:
for my $h (
# values %{$imap->parse_headers( scalar($imap->search("ALL"))
+, "Subject", "Date")}
values %{$imap->parse_headers( scalar($imap->search("SUBJECT"
+,"A time out or a transaction deadlockDDD")) , "Subject", "Date")}
) {
print map { "$_:\t$h->{$_}[0]\n"} keys %$h;
}
So I can search via subject, or just retrieve all. But here's where I'm stuck.
I need for it to search for 3 different subject lines, and I need to search only X minutes in the past, 30 in this case. If a combined 20 or more matches of the 3 subject lines are found, it fires an alert, otherwise it just loops.
I don't understand enough about hashes and keys and map to figure out how to loop through these messages looking for my subject lines. I know I can figure out the go back X minutes from the docs, but the real meat I"m unsure of - any ideas?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.