Gets or sets the selected
Mailbox.
public Mailbox SelectedMailbox {get; set;}
public: __property Mailbox* get_SelectedMailbox();
public: __property void set_SelectedMailbox(
Mailbox* value
);
Public Property SelectedMailbox As Mailbox
Dim instance As Imap
Dim value As Mailbox
instance.SelectedMailbox = value
value = instance.SelectedMailbox
Property Value
Returns the Mailbox that is in the selected state; or null if no Mailbox is selected.
In this example, the Imap component gets messages from a specified mailbox and saves them to disk.
private void getMessages(object sender)
{
//Configure server and account info
imap1.Session.RemoteEndPoint =
new Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session));
imap1.Session.Username = myUsername;
imap1.Session.Password = myPassword;
//Connect and log into the account
imap1.Connect();
imap1.Authenticate();
//Open the mailbox containing the messages to get
imap1.SelectedMailbox = imap1.Mailboxes["INBOX"];
//Specify folder to store messages
string messageFolder = Application.StartupPath + "\\messages";
//Download all messages in the account and save them to disk
foreach (ImapMessage imapMessage in imap1.SelectedMailbox.ToArray())
{
imapMessage.Get();
imapMessage.Message.Save(messageFolder + "\\" + imapMessage.Uid + ".eml");
}
//Gracefully logout of the session
imap1.Close();
}
private void imap1_Progress(object sender, ImapProgressEventArgs e)
{
//Update progress bar as message is sent
progressBar1.Value = (e.Final) ? 0 : (int)((e.Position * 100) / e.Length);
}
Private Sub getMessages(ByVal sender As Object)
'Configure server and account info
imap1.Session.RemoteEndPoint = New Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session))
imap1.Session.Username = myUsername
imap1.Session.Password = myPassword
'Connect and log into the account
imap1.Connect()
imap1.Authenticate()
'Open the mailbox containing the messages to get
imap1.SelectedMailbox = imap1.Mailboxes("INBOX")
'Specify folder to store messages
Dim messageFolder As String = Application.StartupPath & "\messages"
'Download all messages in the account and save them to disk
For Each imapMessage As ImapMessage In imap1.SelectedMailbox.ToArray()
imapMessage.Get()
imapMessage.Message.Save(messageFolder & "\" & imapMessage.Uid & ".eml")
Next imapMessage
'Gracefully logout of the session
imap1.Close()
End Sub
Private Sub imap1_Progress(ByVal sender As Object, ByVal e As ImapProgressEventArgs) Handles imap1.Progress
'Update progress bar as message is sent
progressBar1.Value = If(e.Final, 0, CInt((e.Position * 100) \ e.Length))
End Sub