我正在尝试通过 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>