Exchange配置Office365外部邮件警告遇首尾空格错误求助
解决Exchange外部邮件警告规则创建失败问题
问题分析
你遇到的错误核心是传输规则名称包含末尾空格,Exchange明确禁止规则名称的首尾出现空白字符。此外,你使用的HTML代码存在语法问题,可能导致警告样式渲染异常。
错误提示
Error executing cmdlet:
|Microsoft.Exchange.Data.DataValidationException|Name: The property "Name" with value "Flag External Email Warnings " is invalid. The value can't contain leading or trailing whitespace.
Exception of type 'Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException' was thrown.
原使用的HTML代码
"<p><div style="background-color:#FFEB9C; width:100%; border-style: solid; border-color:#9C6500; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:'Calibri'; color:Black; text-align: left;"><span style="color:#9C6500"; font-weight:bold>CAUTION:</span> This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.</div><br></p>"
分步解决方案
1. 修正规则名称
直接删除规则名称Flag External Email Warnings 末尾的空格,改为Flag External Email Warnings即可解决命名验证失败的问题。
2. 修复HTML代码语法
原HTML存在两处错误:
<span>标签的style属性分号位置错误(应放在双引号内)<p>包裹<div>属于不规范嵌套(块级元素不应嵌套在行内元素中)
修正后的HTML(已转译为中文提示):
<div style="background-color:#FFEB9C; width:100%; border-style: solid; border-color:#9C6500; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:'Calibri'; color:Black; text-align:left;"> <span style="color:#9C6500; font-weight:bold;">注意:</span> 此邮件来自组织外部,除非你认识发件人且确认内容安全,否则请勿点击链接或打开附件。 </div><br>
3. 正确的PowerShell命令示例
如果使用PowerShell创建传输规则,确保名称无首尾空格,同时转义HTML中的单引号(PowerShell中用两个单引号表示一个单引号):
New-TransportRule -Name "Flag External Email Warnings" ` -FromScope NotInOrganization ` -ApplyHtmlDisclaimerLocation Prepend ` -ApplyHtmlDisclaimerText '<div style="background-color:#FFEB9C; width:100%; border-style: solid; border-color:#9C6500; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:''Calibri''; color:Black; text-align:left;"><span style="color:#9C6500; font-weight:bold;">注意:</span>此邮件来自组织外部,除非你认识发件人且确认内容安全,否则请勿点击链接或打开附件。</div><br>'
内容的提问来源于stack exchange,提问作者Ejones90
相关产品推荐
相关产品推荐

