PowerShell Command Line Emailer

I’ve talked about this before, but it came up again today so I thought I’d do a quick post about it.  Here’s a function I use in my PowerShell profile that uses NetCmdlets to send quick “todo” emails:

function todo($target="work", $msg) {
switch ($target)
{
"work" { $target = "lancer@nsoftware.com" }
"home" { $target = "lmrobins@gmail.com" }
}
send-email -from lancer@nsoftware.com -to $target -subject ("Todo: " + $msg) -message $msg -server 10.0.1.1
}

During the day, when I need to send myself a reminder, I can just say:

PS>todo home “remember to buy apples”

or

PS>todo work "schedule meeting with Mark and his team"

 

This is always faster than bringing up my email client, composing a new message and clicking send.  You’ll notice that my function uses the send-email function from NetCmdlets, but just substitute your own email code if necessary.

Technorati Tags: ,

Print | posted on Tuesday, October 20, 2009 8:07 AM

Feedback

No comments posted yet.

Your comment:





 
 

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski