Reputation: 379
How to check how "Sent" mailbox is named ? Somtimes I have to use "INBOX.Sent" sometimes "Sent", I do can not relay on guess I must have a way to check what current name is.
Do you have a way to check it with Chilkat ?
Upvotes: 0
Views: 319
Reputation: 379
Finally I get answer/solution to my problem: I use This example (PowerShell) Find the "Sent" IMAP Mailbox
Here is my version:
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()
And my results are:
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)=
Conclusion: This mean that sometimes Sent should be recognized by a Name not by Flag.
btw. In Polish version of ThunderBird this Mailbox have different name "Wysłane" but location is: similar to "imap://[email protected]/Sent"
Upvotes: 0
Reputation: 1624
Mailboxes contain flags such as "\Sent", "\Trash", "\Junk", etc to indicate the special use mailboxes.
See this example: https://www.example-code.com/csharp/imap_find_sent_mailbox.asp
Upvotes: 1