Solved

Outlook using powershell

Posted on 2014-01-30
1
2,890 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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Outlook Free & Paid Tools
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
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 …

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now