We help IT Professionals succeed at work.

Sending Out Automated Email w/Attachment using Exchange Server 2007


I am interested in knowing if there is an easy way schedule the sending of an email 3 times daily at predetermined times (7am, 4pm, 12am) to an existing universal distribution group with an attachment. I have an excel spreadsheet that is updated throughout the day, and I would like the email to automatically attach this spreadsheet as an attachment and send to the distro group. I am running Outlook 2007 on the desktop and Exchange 2007.


Watch Question

Solutions Architect
use the code below and set it as a .ps1 file, put it in the same location as the excel file

use http://www.zerohoursleep.com/2010/04/how-to-run-exchange-ps1-script-as-scheduled-task/ to schedule it to run when needed
$filename = “file.xls”
$Server = “hubserver”

$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filename)
$smtp = new-object Net.Mail.SmtpClient($Server)

$msg.From = “user@something.com”
$msg.Subject = “Subject goes here”
$msg.Body = “body goes here”


Open in new window


Okay, silly question probably, do I use quotes around the $filename, $Server, $msg.From thru $msg.Body lines?

AkhaterSolutions Architect
the quotes are just where they exist in the script so assuming your servername ins ExchangeSrv

$server = "ExchageSrv"

if the email you want to sent from is you@company.com

$msg.From = “you@copany.com”


Great, thank you Akhater!
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.