本文介绍了欢迎电子邮件脚本交流2007的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Team,


您可以在我的测试脚本下面验证新用户邮箱的欢迎消息。


Add-PSSnapin Microsoft .Exchange.Management.PowerShell.Admin

$ NewUsers = Get-User -ResultSize Unlimited |其中{($ _。WhenCreated -gt(get-date).addhours(-12))}

foreach($ NewUser in $ NewUsers)

{

$ SmtpClient = new-object system.net.mail.smtpClient

$ MailMessage = New-Object system.net.mail.mailmessage

$ SmtpClient。 Host =" HubTRole.domain.com"

$ mailmessage.from =(" [email protected]")

$ Recipient =(Get-Recipient $ NewUser .identity).PrimarySMTPAddress

$ mailmessage.To.add($ Recipient)

$ mailmessage.Subject ="邮件主题"

$ mailmessage .Body ="在这里键入Body ..."

$ smtpclient.Send($ mailmessage)

}



其返回错误如下...


异常调用"新增]用"1"表示"1"。参数:"参数'地址'不能


 是一个空字符串。

参数名称:地址" b $ b在C:\ script \ test.ps1:9 char:20

+ $ mailmessage.To.add(<<<< ; $ Recipient)

异常调用"发送"用"1"表示"1"。参数:"必须指定收件人。"

在C:\ script \ test.ps1:12 char:17

+ $ smtpclient 。发送(<<<<< $ mailmessage)

希望你的冠军回复相同。


问候,


Vimal Thakar


解决方案




Hello Team,

could you verify below my test script for Welcome Msg for new user mailbox.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$NewUsers = Get-User -ResultSize Unlimited | Where {($_.WhenCreated -gt (get-date).addhours(-12))}
foreach ($NewUser in $NewUsers)
{
$SmtpClient = new-object system.net.mail.smtpClient
$MailMessage = New-Object system.net.mail.mailmessage
$SmtpClient.Host = "HubTRole.domain.com"
$mailmessage.from = ("[email protected]")
$Recipient = (Get-Recipient $NewUser.identity).PrimarySMTPAddress
$mailmessage.To.add($Recipient)
$mailmessage.Subject = "Message Subject"
$mailmessage.Body = "Type Body Here..."
$smtpclient.Send($mailmessage)
}

its returning error as below...

Exception calling "Add" with "1" argument(s): "The parameter 'addresses' cannot

 be an empty string.
Parameter name: addresses"
At C:\script\test.ps1:9 char:20
+ $mailmessage.To.add( <<<< $Recipient)
Exception calling "Send" with "1" argument(s): "A recipient must be specified."
At C:\script\test.ps1:12 char:17
+ $smtpclient.Send( <<<< $mailmessage)

Hoping your champ reply for same.

Regards,

Vimal Thakar

解决方案




这篇关于欢迎电子邮件脚本交流2007的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 12:52