Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 将SendAndReceive()与ImapX一起使用_Powershell_Imapx - Fatal编程技术网

Powershell 将SendAndReceive()与ImapX一起使用

Powershell 将SendAndReceive()与ImapX一起使用,powershell,imapx,Powershell,Imapx,我正在尝试有效地使用ImapX DLL。我有$client.Folders.Inbox.Search()和$client.Folders.Inbox.Messages.Download()来下载邮件,但速度非常慢。我正在考虑改用$client.sendandereceive()。我以为它会像Outlook的发送和接收一样工作,但它需要很多我不理解的参数 这是方法定义: bool SendAndReceive(string命令,[ref]System.Collections.Generic.ILi

我正在尝试有效地使用ImapX DLL。我有
$client.Folders.Inbox.Search()
$client.Folders.Inbox.Messages.Download()
来下载邮件,但速度非常慢。我正在考虑改用
$client.sendandereceive()
。我以为它会像Outlook的发送和接收一样工作,但它需要很多我不理解的参数

这是方法定义:
bool SendAndReceive(string命令,[ref]System.Collections.Generic.IList[string]数据,ImapX.Parsing.CommandProcessor处理器,System.Text.Encoding编码,bool pushResultToDataSubsetProcessor)

我不知道这些参数的用途。我在网上搜索了ImapX的文档,但找不到任何有用的东西

sendandereceive()
是下载邮件的好方法吗?如果是,我如何使用它

这是迄今为止我的PowerShell代码:

$DLL = [Reflection.Assembly]::LoadFile(“$PSScriptRoot\DLL\ImapX.dll”)

$client = New-Object ImapX.ImapClient 


$client.IsDebug = $true
$client.ValidateServerCertificate = $true
$client.ThrowConnectExceptions = $true
$client.UseSsl = $false
$client.Behavior.MessageFetchMode = "Full"

$client.Host = $mailHost
$client.Port = $Port

$client.Connect()
$client.Login($user,$password)

# Downloads all messages but very slow
$client.Folders.Inbox.Search("ALL", $client.Behavior.MessageFetchMode)
$client.Folders.Inbox.Messages.Download()

在我看来,它更像是一个用于使dll工作的内部方法,而不是一个应该用于处理dll的方法。我在github上找不到任何docu,也找不到用于实现其他方法的代码,如
Folder.Remove()
Folder.Rename()
。如果您尝试使用MailKit/MimeKit,您将知道ImapX非常简单,并且具有完全不同的复杂性。不幸的是,在几年前的Windows更新之后,它在我的脚本中停止工作,我不得不转到MailKit…你需要定期下载所有邮件吗?通过获取未读邮件或过滤邮件来加快脚本的速度如何?我会查看MimeKit,看看它是否适合我的需要。我仍然希望让
sendandereceive()
working.MimeKit和MailKit是较低级别的库,它们往往更复杂,但也更强大。也就是说,我试图在提供对IMAP、POP3等的较低级别访问和使API易于使用之间取得平衡。大多数其他IMAP库都采取了相反的方式,试图让它们的IMAP客户端反映POP3的简单性,例如“DownloadAllMessages()”,如果您有任何IMAP文件夹像我一样包含10000多条消息,那么这实际上没有多大意义。do:p