Showing posts with label mail. Show all posts
Showing posts with label mail. Show all posts

20 August 2014

Find and delete mail messages in queue

To find messages that are in queue:

Get-Message -Queue "server_name\submission" | where {$_.status -eq "Retry"} -Queue "server_name\submission" | where {$_.status -eq "Retry"}


to delete messages:

Get-Message -Queue "server_name\submission" | where {$_.status -eq "Retry"} | Remove-Message -WithNDR $false 

08 October 2013

Send mail message from powershell


Send-MailMessage -From "user@domain.com" -To "user@domain.com" -Subject "subject" -Body "Message" -SmtpServer servername.local


or by using splatting:


$body = "body message"

$email = @{
From = "user@domain.com"
To = "user@domain.com"
Subject = "subject"
SMTPServer = "servername.local"
Body = $body
}

Send-MailMessage @email