- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 PowerShell 发送电子邮件,但需要使用 TLS。有什么办法可以使用 Send-MailMessage cmdlet 做到这一点?
这是我的代码:
$file = "c:\Mail-content.txt"
if (test-path $file)
{
$from = "afgarciact@gmail.com"
$to = "<slopez@comfama.com.co>","<carloscu@comfama.com.co>"
$pc = get-content env:computername
$subject = "Test message " + $pc
$smtpserver ="172.16.201.55"
$body = Get-Content $file | Out-String
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }
foreach ($recipient in $to)
{
write-host "Sent to $to"
Send-MailMessage -smtpServer $smtpserver -from $from -to $recipient -subject $subject -bodyAsHtml $body -Encoding ([System.Text.Encoding]::UTF8)
}
}
else
{
write-host "Configuración"
}
最佳答案
确保您指定 -UseSsl
转变:
Send-MailMessage -SmtpServer $smtpserver -UseSsl -From $from -To $recipient -Subject $subject -BodyAsHtml $body -Encoding ([System.Text.Encoding]::UTF8)
-Port
范围:
Send-MailMessage -SmtpServer $smtpserver -Port 465 -UseSsl -From $from -To $recipient -Subject $subject -BodyAsHtml $body -Encoding ([System.Text.Encoding]::UTF8)
SecurityProtocol
ServicePointManager
上的属性(property)类(class):
[System.Net.ServicePointManager]::SecurityProtocol = 'Tls,TLS11,TLS12'
关于powershell - 我可以将 TLS 与 Send-MailMessage cmdlet 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39967359/
简单的问题,但我无法在 MSDN 上的任何地方找到答案... 寻找默认的 ASP.NET 将用于: MailMessage.BodyEncoding 和 MailMessage.SubjectEnco
有没有办法将 OpenPop.NET MailMessage 转换为 System.Net.Mail.MailMessage? 最佳答案 如果您使用的是 OpenPop.NET >=version 2
我正在测试通过C#发送一些电子邮件,但是我不知道将IsBodyHtml设置为true有什么效果。无论值(value)如何,我在“正文”中发送的任何内容都会以“文本/纯文本”的内容类型显示,并且HTML
我希望你们能容忍我在线程方面完全缺乏指导。我必须实现邮件队列处理系统,我必须通过 Windows 服务发送在数据库中排队的电子邮件。 这不是生产者-消费者模式。我一次将 10 行数据提取到一个数据表中
我正在尝试使用 将 html 电子邮件的邮件正文设置为其他语言 MailMessage msg = new MailMessage(); msg.BodyEncoding = Encode
我有一个名为 message 的 MailMessage 对象。 我正在尝试创建 message.Body,但我只有一个 IList 来填充它。 在正文中我想要以下内容: "The following
我在将 Properties.Resources 中的图像嵌入到 MailMessage 时遇到了一些困难,目前该图像未显示在我收到的电子邮件中。 我已经成功地从目录位置嵌入了图像,但如果图像来自内存
我正在调用以下代码: public static void SendMessage(string sender, string recipient,string subject,string body
我正在使用 NPOI 创建一个 Excel 工作簿并尝试将其作为电子邮件附件发送。我的代码如下: var wb = new HSSFWorkbook(); //create the workbook
是否可以在 MailMessage 对象上设置发件人姓名?我尝试从 MailAddress 设置它,但 DisplayName 属性似乎是只读的。 我试过“我的名字”作为发件人,但似乎也不起作用。 最
我有一个 Powershell 脚本来发送带有压缩文件附件的电子邮件。在服务器上,zip 文件大约为 16MB。这些电子邮件被我们的 Exchange 服务器拒绝,因为附件太大。我们有 20MB 的限
我正在尝试使用 SmtpClient 发送包含非 ASCII 字符的电子邮件和 MailMessage类。 我正在使用外部邮件服务 ( MailChimp ) 并且我的一些电子邮件已被他们的 SMTP
我有这个简单的脚本: param([string[]]$to="markk", $subject=$null, $body=$null, $from="name", $suffix="@example
我有这个 powershell 脚本来发送带有附件的电子邮件,但是当我添加多个收件人时,只有第一个收件人收到消息。我已经阅读了文档,但仍然无法弄清楚。谢谢 $recipients = "Marcel
这个问题在这里已经有了答案: Powershell send-mailmessage - email to multiple recipients (9 个回答) 4年前关闭。 我尝试编写一个脚本来向
我正在尝试创建一个 PowerShell 脚本,该脚本将在我的 Active Directory 中搜索密码将在 14 天后过期的用户,并通过电子邮件向用户发送提醒消息。在大多数情况下,我的脚本都按预
我搜索了许多论坛,他们确实解释了如何做到这一点,但技术语言太难理解了,因为我对 powershell 非常陌生。我想这一步一步地向我解释(婴儿步骤)。我想在批处理文件 (.bat) 中运行此 powe
我有一个 ASP.NET Web 应用程序,它有一个页面可以将电子邮件发送到收件人列表。此页面有一个 asp:TextBox,其中键入邮件正文: 然后该页面使用 REST 服务将电子邮件详细信息插入
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
使用这个: MailMessage mm = new MailMessage(); 有什么区别: mm.Sender = sender; 和 mm.From = from; ? 谢谢 最佳答案 Sen
我是一名优秀的程序员,十分优秀!