PowerTCP Mail for .NET
Session Property (Pop)
Example 




Specifies connection, authentication and behavior configuration.
Syntax
Public Property Session As MailSession
Dim instance As Pop
Dim value As MailSession
 
instance.Session = value
 
value = instance.Session
public MailSession Session {get; set;}
public: __property MailSession* get_Session();
public: __property void set_Session( 
   MailSession* value
);
public:
property MailSession^ Session {
   MailSession^ get();
   void set (    MailSession^ value);
}

Property Value

MailSession
Remarks
This class is serializable, and can be used to persist a runtime session configuration.
Example
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
See Also

Reference

Pop Class
Pop Members


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic