$user=”lang.wang@slbcopower.com”
$passwd=ConvertTo-SecureString -String “**********” -AsPlainText -Force
$cre=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$passwd
$utf8 = [System.Text.Encoding]::GetEncoding(65001)
$iso88591 = [System.Text.Encoding]::GetEncoding(28591)
$src_string = Invoke-RestMethod -Uri http://blog.sina.com.cn/s/blog_48874cec0102wvxh.html #http://blog.sina.com.cn/s/blog_48874cec0102wvrd.html
$src_bytes = $utf8.GetBytes($src_string)
$des_bytes = [System.Text.Encoding]::Convert($utf8,$iso88591,$src_bytes)
$des_string = $utf8.GetString($des_bytes)
$des_string|Out-File D:\text.txt
$con=Get-Content D:\text.txt
$seg=”(^<p>\d+:\d+.*[\u4e00-\u9f5a]+</p>$)” #正则表达式,^以…开始。\d+数字出现1次及以上,.*匹配所有,[\u4e00-\u9f5a]匹配中文,$以什么结束 正则根据自己的实际需求更改 我这只是个例子 有不完善的自己更改一下
[string]$list=$con -match $seg
Send-MailMessage -From $user -To lang.wang@slbcopower.com -Subject “股票时报” -Body $list -SmtpServer smtp.263.net -Credential $cre -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)