16 Aug 2010

Sending Gmail via PowerShell

[Update: I have updated this blog to display the StackOverflow question using the new StackTack jQuery plugin.]

In a previous post, I looked at reducing the number of mouse clicks and key strokes required to send an email and other common tasks using Launchy.  The solution involved using Outlook, as this was for my work PC.  I started thinking about doing the same on my home laptop, where I don’t have Outlook installed.  I remembered a blog article from Scott Hansleman on using the command line email tool Blat, and thought I could do something similar using a PowerShell script send email via Gmail.

Just to note, the script below is only valid for PowerShell V1; in PowerShell V2, there is a cmdlet available to do this, Send-MailMessage. I’ll look at this using this cmdlet in my next blog post.

A quick search of StackOverflow found the following:

My script is based on the answer submitted by user Christian:

Using the script above, and the previously mentioned way of calling PowerShell scripts from Launchy, I can quickly generate emails with a minimal number of keystrokes.

Download the script from here.  If you have any comments, I would appreciate all feedback.  Thanks.

Also, just to note that the code for this post was highlighted using the BlogTrog website.

1 comment:

  1. Thanks for these scripts. I plan on using this with the new version of powershell on ubuntu.


Note: only a member of this blog may post a comment.