奇尔卡特 IMAP - 如何检查 "Sent" 邮箱名称

Chilkat IMAP - how to check "Sent" mailbox name

如何查看“已发送”邮箱的命名方式? 有时我必须使用“INBOX.Sent”有时“已发送”, 我不能继续猜测我必须有办法检查当前名称是什么。

你有办法用 Chilkat 检查它吗?

邮箱包含“\Sent”、“\Trash”、“\Junk”等标志,表示特殊用途的邮箱。

看这个例子:https://www.example-code.com/csharp/imap_find_sent_mailbox.asp

我终于 answer/solution 解决了我的问题: 我用这个例子 (PowerShell) Find the "Sent" IMAP Mailbox

这是我的版本:

Add-Type -Path "c:\PS1\ChilkatDotNet48_x64.dll"
$glob = New-Object Chilkat.Global
$success = $glob.UnlockBundle("Anything for 30-day trial")
if ($success -ne $true) {
    $($glob.LastErrorText)
    exit
}

$status = $glob.UnlockStatus
if ($status -eq 2) {
    $("Unlocked using purchased unlock code.")
}
else {
    $("Unlocked in trial mode.")
}
$($glob.LastErrorText)


$imap = New-Object Chilkat.Imap

$imap.Ssl = $true
$imap.Port = 993
# connect to server
$success = $imap.Connect("******")
if ($success -ne $true) {
    $($imap.LastErrorText)
    exit
}

# Login or authenticate in some way..
$success = $imap.Login("******","******")
if ($success -ne $true) {
    $($imap.LastErrorText)
    exit
}

# Get the list of mailboxes.
$refName = ""
$wildcardedMailbox = "*"

$mboxes = $imap.ListMailboxes($refName,$wildcardedMailbox)
if ($imap.LastMethodSuccess -eq $false) {
    $($imap.LastErrorText)
    exit
}

# The mailbox with the "/Sent" flag is the "Sent" mailbox.
# Likewise for Junk and Trash..
$i = 0
$("")
$("")
while ($i -lt $mboxes.Count) {
    if ($mboxes.GetName($i) -eq "Sent") {
        $("Sent mailbox (1): " + $mboxes.GetName($i))
        $(" >> mboxes.GetNthFlag(i,0)=" + $mboxes.GetNthFlag($i, 0))
        $(" >> mboxes.GetNthFlag(i,1)=" + $mboxes.GetNthFlag($i, 1))
        $("")
    }
    
    if ($mboxes.HasFlag($i,"\Sent") -eq $true) {
        $("Sent mailbox (2): " + $mboxes.GetName($i))
        $(" >> mboxes.GetNthFlag(i,0)=" + $mboxes.GetNthFlag($i, 0))
        $(" >> mboxes.GetNthFlag(i,1)=" + $mboxes.GetNthFlag($i, 1))
        $("")
    }

    if ($mboxes.HasFlag($i,"\Junk") -eq $true) {
        $("Junk mailbox: " + $mboxes.GetName($i))
        $(" >> mboxes.GetNthFlag(i,0)=" + $mboxes.GetNthFlag($i, 0))
        $(" >> mboxes.GetNthFlag(i,1)=" + $mboxes.GetNthFlag($i, 1))
        $("")
    }

    if ($mboxes.HasFlag($i,"\Trash") -eq $true) {
        $("Trash mailbox: " + $mboxes.GetName($i))
        $(" >> mboxes.GetNthFlag(i,0)=" + $mboxes.GetNthFlag($i, 0))
        $(" >> mboxes.GetNthFlag(i,1)=" + $mboxes.GetNthFlag($i, 1))
        $("")
    }

    $i = $i + 1
}

# Disconnect from the IMAP server.
$success = $imap.Disconnect()

我的结果是:

Junk mailbox: Junk
 >> mboxes.GetNthFlag(i,1)=\HasNoChildren
 >> mboxes.GetNthFlag(i,2)=\Junk

Sent mailbox (1): Sent
 >> mboxes.GetNthFlag(i,1)=\HasChildren
 >> mboxes.GetNthFlag(i,2)=

结论:这意味着有时 Sent 应该通过 Name 而不是 Flag 来识别。

顺便说一句。 在 ThunderBird 的波兰语版本中,此邮箱有不同的名称“Wysłane”,但位置是:类似于“imap://user@domain.com/Sent