积极答复者
自动发送欢迎邮件

问题
答案
-
您好,
经过我的测试,最终修改后的脚本为:
<?xml version="1.0" encoding="UTF-8"?> <Configuration version="1.0"> # Script to send new email starts here <Feature Name="Welcome Email" Cmdlets="New-Mailbox,Enable-Mailbox"> <ApiCall Name="OnComplete"> if($succeeded) { if ($provisioningHandler.TaskName -eq "New-Mailbox") { # Set max send and receive size $Name=$provisioningHandler.UserSpecifiedParameters["Name"] Set-Mailbox -Identity $Name -MaxSendSize 10MB -MaxReceiveSize 10MB # Replace place holder. $USRdname=$provisioningHandler.UserSpecifiedParameters["Name"] $tempmsg= [string] (get-content ("c:\shared\WelcomeMSG.htm")) $tempmsg = $tempmsg -replace "NewUser00",$USRdname # Picking Primary SMTP address,saving to $pSMTP to send email. $Ualias=$provisioningHandler.UserSpecifiedParameters["Alias"] $pSMTP = (get-mailbox $Ualias | select-object PrimarySMTPAddress | Format-Wide | Out-String ).trim() } elseif ($provisioningHandler.TaskName -eq "Enable-Mailbox") { # Picking Primary SMTP address,saving to $pSMTP to send email. $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() # Set max send and receive size $Name= $provisioningHandler.UserSpecifiedParameters["Identity"] $mailbox = get-mailbox $Name.RawIdentity Set-Mailbox -Identity $mailbox -MaxSendSize 10MB -MaxReceiveSize 10MB # Replace place holder. $tempmsg= [string] (get-content ("c:\shared\WelcomeMSG.htm")) $tempmsg = $tempmsg -replace "NewUser00",$dName } # Please give the correct HUB serve IP address in the following line. $HUBServer="192.168.2.51" $EMail =new-object net.mail.mailmessage $HUBTask = new-object net.mail.smtpclient($HUBServer) # Email with attachment will be sent from the address given in the following line. $EMail.From="administrator@contoso.com" # Email with attachment will be sent TO the address given in the following line. $EMail.To.add($pSMTP) # Email Subject and Body details are specified in following lines $EMail.Subject="Welcome to Contoso IT !!!" $EMail.Body= $tempmsg $Email.IsBodyHtml = $true $HUBTask.send($EMail) } </ApiCall> </Feature> # Script to send new email ends here </Configuration>
删掉原来ScriptingAgentConfig.xml里的内容,把上述内容复制进去并保存。上面加粗的地方是需要根据您的环境修改的。
对应的欢迎邮件模板为,邮件的内容是可以编辑的,模板里主题一定要设置为空,主题的内容需要在脚本里设置。"Newuser00 "的地方也不能改。
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已建议为答案 Manu MengModerator 2018年8月28日 4:42
- 已编辑 Manu MengModerator 2018年8月28日 4:44
- 已标记为答案 techboyonline 2018年8月28日 6:34
全部回复
-
您好,
我们一般会使用Exchange服务器自带的命令行扩展代理(Cmdlet Extension Agents)来实现。当新建邮箱时,相当于在后台运行了New-Mailbox这条命令,这条命令会触发服务器调用已经写好的欢迎邮件的HTML模板,并进行自动编辑,然后下一步就是自动发送欢迎邮件。
类似的脚本有很多,这里以“Send Welcome Email to New Mailbox / New Users.”这篇博客为例,主要介绍他的使用方法。
1. 创建欢迎邮件的模板,这里建议在Outlook中新建一封邮件,在里面编辑好内容,然后将它保存为html的格式。
2. 在<installation path>\Bin\CmdletExtensionAgents\路径下找到ScriptingAgentConfig.xml.sample这个文件,使用记事本打开,清空里面的内容,并将上面博客step3中的脚本复制进去,然后将该文件在原路径下保存为ScriptingAgentConfig.xml。注:请根据您的需求自行调整脚本的参数,需要调整的地方已经在step4中提到,包括模板保存的路径,传输服务器(mailbox server)的IP, 管理员的邮箱地址,模板邮件的标题。
3. 启用命令行扩展代理中的脚本代理,运行如下命令:
Enable-CmdletExtensionAgent "Scripting Agent"
4. 新建一个邮箱,打开OWA,检查是否会收到一封欢迎邮件。
希望能帮到您!
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已编辑 Manu MengModerator 2018年8月27日 8:44
-
你好,ScriptingAgentConfig.xml 文件我公司已在使用,其内容的功能为 实现 新建邮箱默认最大收发邮件大小为6兆的设置。exchange server 2013 新建的邮箱默认不指定邮件最大收发大小,因此我们用脚本开启了此功能。
基于上述情况,可以不影响已经设定的功能后,再实现您描述的自动给新建邮箱发送欢迎邮件功能吗?
可以的,将new-mailbox触发的执行脚本放到下图中指定位置即可。
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
-
你好,我们邮件服务器上现在ScriptingAgentConfig.xml 脚本文件的具体内容如下:
<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="MailboxProvisioning" Cmdlets="new-mailbox,enable-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
Set-ADServerSettings -ViewEntireForest $true
$mailbox = $provisioningHandler.UserSpecifiedParameters["Alias"]
Set-Mailbox $mailbox -MaxSendSize 6MB -MaxReceiveSize 6MB
}
</ApiCall>
</Feature>
</Configuration> 如何和您说的脚本内容做结合,既保留原先脚本的功能,又能实现给新建邮箱(我们是依据已建立好的域账号启用邮箱)自动发送欢迎邮件功能? 谢谢!- 已编辑 techboyonline 2018年8月27日 9:46
-
您好,
经过我的测试,最终修改后的脚本为:
<?xml version="1.0" encoding="UTF-8"?> <Configuration version="1.0"> # Script to send new email starts here <Feature Name="Welcome Email" Cmdlets="New-Mailbox,Enable-Mailbox"> <ApiCall Name="OnComplete"> if($succeeded) { if ($provisioningHandler.TaskName -eq "New-Mailbox") { # Set max send and receive size $Name=$provisioningHandler.UserSpecifiedParameters["Name"] Set-Mailbox -Identity $Name -MaxSendSize 10MB -MaxReceiveSize 10MB # Replace place holder. $USRdname=$provisioningHandler.UserSpecifiedParameters["Name"] $tempmsg= [string] (get-content ("c:\shared\WelcomeMSG.htm")) $tempmsg = $tempmsg -replace "NewUser00",$USRdname # Picking Primary SMTP address,saving to $pSMTP to send email. $Ualias=$provisioningHandler.UserSpecifiedParameters["Alias"] $pSMTP = (get-mailbox $Ualias | select-object PrimarySMTPAddress | Format-Wide | Out-String ).trim() } elseif ($provisioningHandler.TaskName -eq "Enable-Mailbox") { # Picking Primary SMTP address,saving to $pSMTP to send email. $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() # Set max send and receive size $Name= $provisioningHandler.UserSpecifiedParameters["Identity"] $mailbox = get-mailbox $Name.RawIdentity Set-Mailbox -Identity $mailbox -MaxSendSize 10MB -MaxReceiveSize 10MB # Replace place holder. $tempmsg= [string] (get-content ("c:\shared\WelcomeMSG.htm")) $tempmsg = $tempmsg -replace "NewUser00",$dName } # Please give the correct HUB serve IP address in the following line. $HUBServer="192.168.2.51" $EMail =new-object net.mail.mailmessage $HUBTask = new-object net.mail.smtpclient($HUBServer) # Email with attachment will be sent from the address given in the following line. $EMail.From="administrator@contoso.com" # Email with attachment will be sent TO the address given in the following line. $EMail.To.add($pSMTP) # Email Subject and Body details are specified in following lines $EMail.Subject="Welcome to Contoso IT !!!" $EMail.Body= $tempmsg $Email.IsBodyHtml = $true $HUBTask.send($EMail) } </ApiCall> </Feature> # Script to send new email ends here </Configuration>
删掉原来ScriptingAgentConfig.xml里的内容,把上述内容复制进去并保存。上面加粗的地方是需要根据您的环境修改的。
对应的欢迎邮件模板为,邮件的内容是可以编辑的,模板里主题一定要设置为空,主题的内容需要在脚本里设置。"Newuser00 "的地方也不能改。
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已建议为答案 Manu MengModerator 2018年8月28日 4:42
- 已编辑 Manu MengModerator 2018年8月28日 4:44
- 已标记为答案 techboyonline 2018年8月28日 6:34