Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Powershell电子邮件中设置HTML字体颜色_Html_Email_Powershell_Fonts_Colors - Fatal编程技术网

在Powershell电子邮件中设置HTML字体颜色

在Powershell电子邮件中设置HTML字体颜色,html,email,powershell,fonts,colors,Html,Email,Powershell,Fonts,Colors,我有一个powershell脚本,它将为密码将在中过期的用户生成电子邮件。您看过powershell的“here string”功能了吗?有一个问题。我总是用它们来表示字符串,这些字符串是东西的模板 我喜欢在这样的模板中使用c风格的占位符,比如{0}。这允许对日期和货币进行奇特的格式设置。(在我的示例中,我使用了一种“奇特”的日期格式。) 使用带有占位符的模板也意味着我不必记住以特定顺序将字符串连接在一起,也不必记住$firstname之类的东西必须放在这些组合中。它也应该更容易国际化,但我从来

我有一个powershell脚本,它将为密码将在中过期的用户生成电子邮件。您看过powershell的“here string”功能了吗?有一个问题。我总是用它们来表示字符串,这些字符串是东西的模板

我喜欢在这样的模板中使用c风格的占位符,比如{0}。这允许对日期和货币进行奇特的格式设置。(在我的示例中,我使用了一种“奇特”的日期格式。)

使用带有占位符的模板也意味着我不必记住以特定顺序将字符串连接在一起,也不必记住$firstname之类的东西必须放在这些组合中。它也应该更容易国际化,但我从来没有这样做过

这里是一个快速的例子,您需要将其集成到您的循环逻辑中

# first, stick the template into a variable for later use. Use a "here string" for ease of formatting and editting.
$bodyTemplate = @"
{0} {1}
<html><body><br> Your network password will expire in {2} day(s).</body><html>
<html><body><br>Employees of Organization, when you receive this email please visit https://scriptlogic/iisadmpwd/aexp2b.asp to reset your network password.
<br>If you are <font color =""#99000"">not employed by Organization</font>, please visit https://gateway.organization.org to reset your network password using our Citrix website.
<br>If you need assistance resetting your password, please contact the Ibformation Service Department at 867-5309
<br>If you have a portable device, smart phone, etc. that you use to access the Network the new password will need to be updated on these devices also.
<br><br>Thank you,
<br> IS Department
<br><img src='P:\Documents\PowerShell\Scripts\password\logo.jpg' alt='logo'/>
<br><br><hr>
From <b> IS Department</b>
<br>The information contained in this e-mail and any accompanying documents is confidential, may be privileged, and is intended solely for the person and/or entity to whom it is
<br>addressed (i.e. those identified in the <b> To: </b> and <b> cc:</b> box). They are the property of this organization. Unauthorized review, use, disclosure, or copying of this
communication, or any part thereof, is strictly prohibited and may be unlawful.  The IT Department thanks you for your cooperation.<br>
{3:D}
<br><hr><br></body></html>
"@

# Now, loop through your users, calculate $DaysUntilExpiry, test the value and build the email to be sent
# I'm just making up some dumb values here
$daystoexpire = 42 # or whatever
$firstname =  "George"
$lastname = "Washington"
$date = date

# using the template, stick the appropriate values into place and store that in a variable for convenience
$body = $bodyTemplate -f $firstname, $lastname, $daystoexpire, $date

# do whatever we want with $body
write-host $body
#首先,将模板粘贴到一个变量中以备以后使用。使用“此处字符串”以便于格式化和编辑。
$bodyTemplate=@”
{0} {1}

您的网络密码将在{2}天后过期。
组织的员工,当您收到此电子邮件时,请访问https://scriptlogic/iisadmpwd/aexp2b.asp 重置网络密码。
如果您不是该组织的雇员,请访问https://gateway.organization.org 使用我们的Citrix网站重置您的网络密码。
如果您需要重置密码的帮助,请致电867-5309与iInformation服务部门联系
如果您有用于访问网络的便携式设备、智能手机等,则还需要在这些设备上更新新密码。

谢谢,,




来自IS部门
本电子邮件和任何随附文件中包含的信息均为机密信息,可能具有特权,且仅适用于接收该信息的个人和/或实体
地址(即收件人:和抄送:框中标识的地址)。它们是本组织的财产。未经授权审查、使用、披露或复制本文件 通信或其任何部分都是严格禁止的,可能是非法的。IT部门感谢您的合作。
{3:D}


"@ #现在,遍历您的用户,计算$daysuntileexpire,测试值并生成要发送的电子邮件 #我只是在编造一些愚蠢的价值观 $daystoexpire=42#或其他 $firstname=“乔治” $lastname=“华盛顿” $date=日期 #使用模板,将适当的值粘贴到位,并将其存储在变量中以方便使用 $body=$bodyTemplate-f$firstname、$lastname、$daystoexpire、$date #我们想用$body做什么就做什么 写入主机$body
感谢您为我指出这一点。它的工作与一个小的调整。双引号和#组合的力量将句子的其余部分注释掉,但我将代码改为,它成功了。还感谢您提供有关使用c#placeholder的提示。这将在未来的脚本中非常有用。
# first, stick the template into a variable for later use. Use a "here string" for ease of formatting and editting.
$bodyTemplate = @"
{0} {1}
<html><body><br> Your network password will expire in {2} day(s).</body><html>
<html><body><br>Employees of Organization, when you receive this email please visit https://scriptlogic/iisadmpwd/aexp2b.asp to reset your network password.
<br>If you are <font color =""#99000"">not employed by Organization</font>, please visit https://gateway.organization.org to reset your network password using our Citrix website.
<br>If you need assistance resetting your password, please contact the Ibformation Service Department at 867-5309
<br>If you have a portable device, smart phone, etc. that you use to access the Network the new password will need to be updated on these devices also.
<br><br>Thank you,
<br> IS Department
<br><img src='P:\Documents\PowerShell\Scripts\password\logo.jpg' alt='logo'/>
<br><br><hr>
From <b> IS Department</b>
<br>The information contained in this e-mail and any accompanying documents is confidential, may be privileged, and is intended solely for the person and/or entity to whom it is
<br>addressed (i.e. those identified in the <b> To: </b> and <b> cc:</b> box). They are the property of this organization. Unauthorized review, use, disclosure, or copying of this
communication, or any part thereof, is strictly prohibited and may be unlawful.  The IT Department thanks you for your cooperation.<br>
{3:D}
<br><hr><br></body></html>
"@

# Now, loop through your users, calculate $DaysUntilExpiry, test the value and build the email to be sent
# I'm just making up some dumb values here
$daystoexpire = 42 # or whatever
$firstname =  "George"
$lastname = "Washington"
$date = date

# using the template, stick the appropriate values into place and store that in a variable for convenience
$body = $bodyTemplate -f $firstname, $lastname, $daystoexpire, $date

# do whatever we want with $body
write-host $body