2014-03-05 26 views
0

繼用來從PowerShell的如何將電子郵件發送到收件人組在PowerShell中

Function Mailer ($emailTo) 
{ 
$message = @" 

Some stuff that is meaningful 

Thank you, 
IT Department 
Cotendo Corporation 
[email protected] 
"@   

$emailFrom = "[email protected]<yourdomain>.com" 
$subject="<Your Text Here>" 
$smtpserver="<your mailhost>.<yourdomain>.com" 
$smtp=new-object Net.Mail.SmtpClient($smtpServer) 
$smtp.Send($emailFrom, $emailTo, $subject, $message) 
} 

發送電子郵件上面的代碼幫我從PowerShell腳本發送電子郵件塊。我可以發送電子郵件到個人電子郵件,如[email protected],但如果有羣組電子郵件或AD羣組電子郵件收件人,那麼我不能。

請幫我把電子郵件發送到AD組或電子郵件ID,是特殊權限要求還是我可以使用上面的腳本發送。

回答

2
Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String> ] [[-SmtpServer] <String> ] -From <String> [-Attachments <String[]> ] [-Bcc <String[]> ] [-BodyAsHtml] [-Cc <String[]> ] [-Credential <PSCredential> ] [-DeliveryNotificationOption <DeliveryNotificationOptions> ] [-Encoding <Encoding> ] [-Port <Int32> ] [-Priority <MailPriority> ] [-UseSsl] [ <CommonParameters>] 

http://community.spiceworks.com/topic/434439-how-do-i-have-powershell-send-an-email-to-multiple-recipients

你可以按照這個鏈接發送多個用戶的腳本有

+0

它爲我工作。謝謝。 – ppatil

相關問題