Dart.Mail Namespace > Mailbox Class > Add Method : Add(Stream,ImapFlags,DateTime) Method |
Public Overloads Sub Add( _ ByVal encodedMessage As Stream, _ ByVal flags As ImapFlags, _ ByVal date As Date _ )
Exception | Description |
---|---|
ProtocolException | Bad IMAP protocol response received from server. |
System.Net.Sockets.SocketException | A communications failure has occurred. |
private void uploadMessage(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; //Create message to upload MailMessage message = new MailMessage(); message.From = fromAddress; message.To = toAddress; message.Subject = "This is an uploaded message"; message.Text = "This is an uploaded message."; //Connect and log into the account imap1.Connect(); imap1.Authenticate(); //Select mailbox to upload message to (assumes a 'Save' mailbox exists) imap1.SelectedMailbox = imap1.Mailboxes["Save"]; //Upload the message imap1.SelectedMailbox.Add(message.GetEncodingStream(), ImapFlags.None, DateTime.Now); //Gracefully logout of the session imap1.Close(); }
Private Sub uploadMessage(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 'Create message to upload Dim message As New MailMessage() message.From = fromAddress message.To = toAddress message.Subject = "This is an uploaded message" message.Text = "This is an uploaded message." 'Connect and log into the account imap1.Connect() imap1.Authenticate() 'Select mailbox to upload message to (assumes a 'Save' mailbox exists) imap1.SelectedMailbox = imap1.Mailboxes("Save") 'Upload the message imap1.SelectedMailbox.Add(message.GetEncodingStream(), ImapFlags.None, Date.Now) 'Gracefully logout of the session imap1.Close() End Sub