PowerTCP Mail for .NET
Add(Stream,ImapFlags,DateTime) Method
Example 




Stream containing the encoded message.
The ImapFlags to set on the message.
A System.DateTime representing the internal date to use for the message.
Adds a new message with customized attributes to the mailbox using APPEND.
Syntax
Public Overloads Sub Add( _
   ByVal encodedMessage As Stream, _
   ByVal flags As ImapFlags, _
   ByVal date As Date _
) 
Dim instance As Mailbox
Dim encodedMessage As Stream
Dim flags As ImapFlags
Dim date As Date
 
instance.Add(encodedMessage, flags, date)
public void Add( 
   Stream encodedMessage,
   ImapFlags flags,
   DateTime date
)
public: void Add( 
   Stream* encodedMessage,
   ImapFlags flags,
   DateTime date
) 
public:
void Add( 
   Stream^ encodedMessage,
   ImapFlags flags,
   DateTime date
) 

Parameters

encodedMessage
Stream containing the encoded message.
flags
The ImapFlags to set on the message.
date
A System.DateTime representing the internal date to use for the message.
Exceptions
ExceptionDescription
ProtocolExceptionBad IMAP protocol response received from server.
System.Net.Sockets.SocketExceptionA communications failure has occurred.
Remarks
Sends an APPEND command to the IMAP server, adding encodedMessage to this mailbox. flags determines which flags are set on the new message. date sets the internal date (the date the message arrived on the server). The newly added message will not be listed in the mailbox until the mailbox is updated by initiating another operation on the server. To manually update the mailbox, call Imap.Noop().
Example
This example demonstrates using the Imap component to upload a message to the mail server.
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
See Also

Reference

Mailbox Class
Mailbox Members
Overload List


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