如何解决PowerShell 从 html 解析电子邮件
我正在尝试通过 PowerShell 使用您的 impx.dll,但在尝试解析 html 时遇到了困难。
是否有任何示例可以帮助我或为我指明正确的方向。
我是 powershell 的新手,需要任何我能得到的帮助。 - 提前致谢!
我正在使用以下内容:
Start-Transcript -path C:\log.txt -append
$path = "C:\scripts"
[Reflection.Assembly]::LoadFile(“$path\imapx.dll”)
$Username = "user"
$Password = "pass"
# Initialize the IMAP client
$client = New-Object ImapX.ImapClient
###set the fetching mode to retrieve the part of message you want to retrieve,###the less the better
$client.Behavior.MessageFetchMode = "Full"
$client.Host = "webmailserverblabla"
$client.Port = 993
$client.UseSsl = $true
$client.Connect()
$client.Login($Username,$Password)
$messages = $client.Folders.Inbox.Search("ALL",$client.Behavior.MessageFetchMode,100)
# Counts the number of emails in the inbox
write-host "Count found: $($messages.count)"
# loops through inbox for all subjects and writes them
foreach($m in $messages){
$m.From.Address
$m.Subject
$m.UId
$m.body.Text
$m.DownloadRawMessage()
}
Output to parse:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
</style>
</head>
<body lang="EN-US" link="#xxxxxx" vlink="#xxxxxx" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Test<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:#63666A">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#005CB9">James</span></b><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#005CB9"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。