Friday, August 30, 2013

Powershell and Outlook : Create and send a new email using Powershell “OutlookTools” Module.

 

Hi,

I have added a new functionality in “OutlookTools” module. Now we can compose and send a new emails using “New-OutlookEmail” function.

This function also do support adding attachments to the composed email, but for now we can attach only one single file.

“OutlookTools” Module download link: https://github.com/AmanDhally/OutlookTools

Let’s start

 

  1. First download the “OutlooTools.Psm1” and .psd1 file fromhttps://github.com/AmanDhally/OutlookTools
  2. Create a folder Name “OutlookTools” in “Libraries\Documents\WindowsPowershell\Modules
  3. and paste both files there.

12-08-2013 1 
Now open Powershell console and run the cmdlet, 

Import-Module OutlookTools

12-08-2013 2

By running the Get-Command cmdlet, we can see which cmdlet and function this modules had added.

Get-Command -Module outlooktools

0

You can see now , we have New-OutlookEmail listed in Function.

How to use it?

It’s simple.

Create a new email.

We are creating a new email , to amandhally@gmail.com with subject “Sending from Powershell” and with body text “Heya its working”

New-OutlookEmail -To amandhally@gmail.com -Subject "Sending from Powershell" -Body "Heya! its working"

1

and when you hit enter, you encountered this problem. ,

I haven’t solved it yet and i am working on it. :( .

2 

but when you click on “Allow”. this will send an email.

You can see, the email is come to our Sent Items folder.

3

and i received it on my Gmail id too.

4

Now create an email with attachment.

Now , we are creating a new email , with attachment, and with High Priority.

New-OutlookEmail -To "amandhally@gmail.com" -Subject "Attaching file"  -Attachment 'D:\a.txt' -importance 2

5

now when you click on send, the above problem comes again with one more confirmation box.,

6

7

once you click on Allows on both.

the email will be in Sent Item

8

and i received it on my Gmail id with attachments too.

9

“OutlookTools” Module download link: https://github.com/AmanDhally/OutlookTools

i hope you will like it.

Thanks
Aman Dhally
clip_image001 clip_image002 clip_image003 clip_image005clip_image007

1 comment:

  1. This is an issue with anti-virus program or addin pushed in outlook by anti-virus program. in the past had an issue when using VBA. Tested multiple antivirus but for me Microsoft security essentials works good.

    ReplyDelete

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