如何在邮件中加入html代码,如何在电子邮件正文中嵌入HTML文件

如何使用powershell在电子邮件正文中嵌入HTML文件?这就是我到目前为止所做的:

##Connect to the data source using the connection details and T-SQL command we provided above, and open the connection

$connection = New-Object System.Data.OleDb.OleDbConnection $connectionDetails

$command = New-Object System.Data.OleDb.OleDbCommand $sqlCommand,$connection

$connection.Open()

##Get the results of our command into a DataSet object, and close the connection

$dataAdapter = New-Object System.Data.OleDb.OleDbDataAdapter $command

$dataSet = New-Object System.Data.DataSet

$dataAdapter.Fill($dataSet)

$connection.Close()

$body = $TableHeader

$dataSet.Tables | Select-Object -Expand Rows |

Select-Object * -ExcludeProperty Comment, RowError, RowState, Table, ItemArray, HasErrors |

ConvertTo-HTML -head $a –body $body |

Out-File $OutputFile

$ReportLink = "file://serverr/c$/Output/Report.Html"

Write-Output " Reporting"

$MailUsername = "you"

$MailPassword = "your pasword"

$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($MailUsername,(ConvertTo-SecureString -String $MailPassword -AsPlainText -Force))

Send-MailMessage -To "abc@ymail.com" -From "xyz@ymail.com" -SmtpServer Ymail -Credential $cred -Subject " Report:" -Body $ReportLink -BodyAsHtml

我仍然是PowerShell的新手。提前谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值