Solved

Outlook using powershell

Posted on 2014-01-30
1
3,385 Views
Last Modified: 2014-01-30
Hi

Trying to create a powershell script to send emails via outlook 2010 to multiple recipients, attach files from a specified location.

Please advise the best way to proceed with this. Thanks
0
Comment
Question by:ahmedla1
1 Comment
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39820440
You may use Send-MailMessage command which doesn’t require outlook..
Here is an example..
$to="User@domain.com","User2@domain.com"
Send-MailMessage -From "Sub@domain.com" -To $to -Subject "Testing" -Body "This is my test mail" -Attachments "C:\temp\test.txt" -SmtpServer smtp.domain.com

Open in new window

Refer this article for more details about Send-MailMessage
http://technet.microsoft.com/en-us/library/hh849925.aspx

If you want to use outlook then, here is an example..
$ol = New-Object -comObject Outlook.Application  
$mail = $ol.CreateItem(0)  
$Mail.Recipients.Add("User1@domain.com") 
$Mail.Recipients.Add("User2@domain.com") 
$Mail.Attachments.Add("C:\temp\test.txt") 
$Mail.Subject = "Testing"  
$Mail.Body = "This is my test mail"  
$Mail.Send() 

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question