Solved

Outlook using powershell

Posted on 2014-01-30
1
3,455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
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…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

733 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