Solved

Outlook using powershell

Posted on 2014-01-30
1
3,169 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

786 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