询问者
关于exchange 2016自动发送欢迎邮件

问题
-
使用下面的脚本自动发送欢迎邮件给新邮箱用户
Send Welcome Email to New Mailbox / New Users.
https://gallery.technet.microsoft.com/office/Send-Welcome-Email-to-New-88cde35c
修改exchange 2016 xml文件后创建邮箱用户报错,详细过程见:
https://partnersupport.microsoft.com/zh-hans/mpndataplat/forum/mpncatwinsvr-mpnws2012/exchange/fe822edd-f949-4acf-905d-098c2a357c63
是否存在兼容性问题?
- 已编辑 席萌 2017年1月5日 6:05
全部回复
-
您好,
感谢联系我们社区。
很抱歉,您的第二个链接我们无法打开,因为需要Partner 账号。
针对您目前的问题就像第一个链接文章提到的, XML文件 示例包含其他功能块。 如果您按照文章所示步骤,而不对其他功能块进行更改,则在创建新邮箱时可能会收到意外的警告。
如果您没有使用cmdlet扩展样本文件而用于任何其他目的/任务,我们建议您只保留欢迎电子邮件功能块,就像文章中的附件所示。
另外请问能否把创建邮箱是的报错信息给截图或者贴出来,方便进一步排错。
另外您也可以参考下面文章的步骤并对照之前步骤看是否有遗漏:
https://gallery.technet.microsoft.com/office/Send-Welcome-Mail-to-Each-4fff4a93
https://blogs.technet.microsoft.com/sukum/2014/07/10/send-welcome-email-to-new-mailbox-new-users/
希望可以帮到您且感谢您的努力。
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.- 已建议为答案 Jason.Chao 2017年1月9日 8:33
-
HI Jason,我测试过只保留发送欢迎邮件模块,创建账户时发生警告,不会发送欢迎邮件,在partner论坛上发帖工程师说这个脚本可能对对windows server 2012 R2或exchange 2016兼容性不好,你提供的连接之前也参考过,未发现异常,因此一直未找到其他解决方法或替代方式,报错如下:
Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: 对 OnComplete API 调用 Scriptlet 时引发了异常: 使用“1”个参数调用“Send”时发生异常:“事务失败。 服务器响应为:5.6.0 Invalid message content”。 ---> System.Management.Automation.MethodInvocationException: 使用“1”个参数调用“Send”时发生异常:“事务失败。 服务器响应为:5.6.0 Invalid message content” ---> System.Net.Mail.SmtpException: 事务失败。 服务器响应为:5.6.0 Invalid message content 在 System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse) 在 System.Net.Mail.DataStopCommand.Send(SmtpConnection conn) 在 System.Net.ClosableStream.Close() 在 System.Net.Mail.SmtpClient.Send(MailMessage message) 在 CallSite.Target(Closure , CallSite , Object , Object ) --- 内部异常堆栈跟踪的结尾 --- 在 System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo) 在 CallSite.Target(Closure , CallSite , Object , Object ) 在 System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 在 System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) 在 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) --- 内部异常堆栈跟踪的结尾 --- 在 Microsoft.Exchange.ProvisioningAgent.ScriptingAgentHandler.OnComplete(Boolean succeeded, Exception e) 在 Microsoft.Exchange.Provisioning.ProvisioningLayer.OnCompleteImpl(Task task, Boolean succeeded, Exception exception)
- 已编辑 席萌 2017年1月10日 1:57
-
您好,
感谢您的回复。
根据我的测试下面的是可以运行成功的对Exchange server 2016,请按照以下步骤:
1. 此方法不用重启服务或服务器
2. 需要替换所有Exchange 2016服务器的 ScriptingAgentConfig.xml.sample 文件
以下为打开一个Scripting Agent的功能 , 并使用其为新建邮箱发送欢迎邮件的详细步骤:
1. 准备发送欢迎邮件的脚本,以下脚本我已经调试过可以正常使用,请根据您的实际情况适当调整里面的值:
请直接使用下面脚本:
<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="Welcome Email" Cmdlets="New-Mailbox,Enable-Mailbox">
<ApiCall Name="OnComplete">
if($succeeded) {
if ($provisioningHandler.TaskName -eq "New-Mailbox") {
$USRdname=$provisioningHandler.UserSpecifiedParameters["Identity"]
$tempmsg= [string] (get-content ("c:\welcome.htm"))
$tempmsg = $tempmsg -replace "NewUser00",$USRdname
$Ualias=$provisioningHandler.UserSpecifiedParameters["Alias"]
$pSMTP = (get-mailbox $Ualias | select-object PrimarySMTPAddress | Format-Wide | Out-String ).trim()
}
elseif ($provisioningHandler.TaskName -eq "Enable-Mailbox") {
$eUalias=$provisioningHandler.UserSpecifiedParameters["Alias"]
$dName = (get-mailbox $eUalias | select-object Name | Format-Wide | Out-String ).trim()
$pSMTP = (get-mailbox $eUalias | select-object PrimarySMTPAddress | Format-Wide | Out-String ).trim()
$tempmsg= [string] (get-content ("c:\welcome.htm"))
$tempmsg = $tempmsg -replace "NewUser00",$dName
}
$HUBServer="10.83.40.35"
$EMail =new-object net.mail.mailmessage
$HUBTask = new-object net.mail.smtpclient($HUBServer)
$EMail.From="momohr@immomo.com"
$EMail.To.add($pSMTP)
$EMail.Subject="welcome to Microsoft!"
$EMail.Body= $tempmsg
$Email.IsBodyHtml = $true
$HUBTask.send($EMail)
}
</ApiCall>
</Feature>
</Configuration>注意:get-content 后面引用的路径一定要有访问的权限,这个地方放置欢迎邮件模板。$HUBServer填写邮箱服务器的IP地址,$EMail.From 和$EMail.Subject根据自己实际需要进行更改。
2. 到任意一台Exchange 服务器上把<installation path>\Bin\CmdletExtensionAgents\ 目录下的 ScriptingAgentConfig.xml.sample copy 出来
3. 删除.sample 后缀
4. 修改里面的内容, 请调整后的脚本 copy 到ScriptingAgentConfig.xml 文件里 , 你可以删除其他Feature ,也可以在其他Feature 后添加 这个 send welcome email Feature
如果你只想使用send welcome 这一个功能, 建议就只把这个Feature 放到xml 文件里
5. 将修改后的xml 文件 copy 到每一台服务器上的<installation path>\Bin\CmdletExtensionAgents\ 目录下
6. 开启 scripting agent 脚本的功能
Get-CmdletExtensionAgent | FT Name,Enabled –autosize
Enable-CmdletExtensionAgent "Scripting Agent"
我的测试结果如下:
希望可以帮到您。
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
- 已编辑 Jason.Chao 2017年1月11日 2:02
- 已建议为答案 Jason.Chao 2017年1月12日 5:09
- 已标记为答案 席萌 2017年1月19日 7:04
- 取消答案标记 席萌 2017年2月14日 8:34
-
您好,
请问上面的回复是否对您有所帮助,如果需要进一步的支持,请及时反馈给我们。
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
感谢您的回复,
根据报错内容确实提示是无效的消息内容。
第一,确保对htm 文件所在的路径有访问的权限;
第二,您可以更换另外的htm 文件进行测试。
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
Hi,
我是在txt文档中写的,然后转化成htm文件格式的,您可以测试一下。
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
您好,请问您有自己用txt文档,建立邮件薄板进行测试吗? 结果如何。
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
感谢您的回复,请保持更新。如果上面的回复对您有所帮助的话,请帮助标记为答复,会对其他客户有所帮助,感谢您的努力和时间。
祝新年快乐!
Regards,
Jason Chao
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
HI jason,卸载完2010后启用邮箱还是报错,无法正常发送欢迎邮件,您那边是否还有其他替代方法?
具备索引 5 的 cmdlet 扩展代理在 OnComplete() 中引发了异常。异常情况为: Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: 对 OnComplete API 调用 Scriptlet 时引发了异常: 使用“1”个参数调用“Send”时发生异常:“事务失败。 服务器响应为:5.6.0 Invalid message content”。 ---> System.Management.Automation.MethodInvocationException: 使用“1”个参数调用“Send”时发生异常:“事务失败。 服务器响应为:5.6.0 Invalid message content” ---> System.Net.Mail.SmtpException: 事务失败。 服务器响应为:5.6.0 Invalid message content 在 System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse) 在 System.Net.Mail.DataStopCommand.Send(SmtpConnection conn) 在 System.Net.Mail.SmtpClient.Send(MailMessage message) 在 CallSite.Target(Closure , CallSite , Object , Object ) --- 内部异常堆栈跟踪的结尾 --- 在 System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo) 在 CallSite.Target(Closure , CallSite , Object , Object ) 在 System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 在 System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) 在 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) --- 内部异常堆栈跟踪的结尾 --- 在 Microsoft.Exchange.ProvisioningAgent.ScriptingAgentHandler.OnComplete(Boolean succeeded, Exception e) 在 Microsoft.Exchange.Provisioning.ProvisioningLayer.OnCompleteImpl(Task task, Boolean succeeded, Exception exception)