Я пытаюсь отформатировать формулировку того, как я получаю электронное письмо, чтобы оно содержало только URL-адрес ссылки и заголовок ссылки на веб-сайт. У меня есть сценарий, тянущий innerText с помощью href в данный момент
Есть ли способ отформатировать href в содержимом электронной почты, чтобы он был более разборчивым?
<#Gets news based on 24 hour search criteria from Google#> $url ="https://www.google.com/search?q=this+is+a+test&sxsrf=ACYBGNQBx5fMzfpxKm96-8tVbjo2vUn3SA:1573134980847&source=lnt&tbs=qdr:d&sa=X&ved=0ahUKEwin4t29oNjlAhXDc98KHfFwAVcQpwUIKQ&biw=1366&bih=625" $date = get-date -Uformat "%m-%d" $response = Invoke-WebRequest -URI $url $file = "F:\rryu\exportfile"+$date+".csv" <#Gets title and href where href url has "/url?1=https://..." and exports it to network drive.#> $response.Links |select-object innerText, href | where-Object {$_.href -like "/url?q=https://*"} | export-csv -path $file -NoTypeInformation <#Makes the csv file to a string#> $stringout = Get-Content $file | Out-String <#Options to send out email out#> $options = @{ 'SmtpServer' = "mailrelay.xxxxxxxxxx.com" 'To' = "xxx <xxx.xxx@xxxxxxxxxx.com>" 'From' = "NoReply <donotreply@xxxxxxxxcx.com>" 'Subject' = "Testing Recent News" 'Body' = "Please review news as of "+$date + $stringout 'Attachments' = $file } Send-MailMessage @options
Ожидаемые результаты:
Это тест ... https://www.tested.com/this-is-only-a-test/
Фактические результаты:
"Это всего лишь тест -Протестировано https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.tested.com&data=02%7C01%7Cxxx.xxxx%40xxxxxxxxx.com%7Cdcd591d873414f6793ea08d7638b6df9%7C50488be8ac744dcd9bdd44db35d92d8d%7C1%7C0%7C637087322814017205&sdata=DAGocTHvYwPcLGIz%2FDOsE7qaoD2lRNrI7nBYaJ3EHK0%3D&reserved=0 «Это тест только для теста», / url? Q = https://www.tested.com/this-is-only-a-test/&sa=U&ved=2ahUKEwigs72motjlAhVpFjQIHRStBTcQFjAAegQIBRAB&usg=AOvVaw1JTUKGetVOagK6UxYKtidf"