Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

Supressing prompts when sending e-mail with Outlook

I am sending an e-mail with MS Outlook via PowerShell and the script below works great, except it displays a number of prompts which i want to suprss, since in the future the script will run from Windows scheduler. Can anyone help?

$ol = New-Object -comObject Outlook.Application 
$message = $ol.CreateItem(0)
$message.Recipients.Add("test@me.com")  
$message.Subject = "Report"  
$message.Body = "Attachment contains one report"

# Attach a file 
$file = "C:\TestReport.csv"

$message.Attachments.Add($file)
$message.Send()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Angelp1ay
Angelp1ay
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of footech
I would ask why you are sending via Outlook instead of just using the Send-MailMessage cmdlet.
Avatar of YZlat

ASKER

I can only use SMTP server name on production servers but to send e-mail from development machine I cannot use Send-MailMessage. Outlook allows me not to spcify SMTP server
Avatar of YZlat

ASKER

Thanks