I'm trying to use you impx.dll via PowerShell and am have difficulties trying to parse out the html.
Are there any examples anyon can help me with or point me in the right direction.
I am new to powershell and need any help I can get. - Thanks in advance!
I am using the following:
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>