| Visual Basic (Declaration) | |
|---|---|
Public Overloads Overridable Function Add( _ ByVal message As Stream, _ ByVal flags As ImapFlags, _ ByVal internalDate As Date _ ) As ImapMessage | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As ImapMessageCollection Dim message As Stream Dim flags As ImapFlags Dim internalDate As Date Dim value As ImapMessage value = instance.Add(message, flags, internalDate) | |
| C# | |
|---|---|
public virtual ImapMessage Add( Stream message, ImapFlags flags, DateTime internalDate ) | |
| Managed Extensions for C++ | |
|---|---|
public: virtual ImapMessage* Add( Stream* message, ImapFlags flags, DateTime internalDate ) | |
| C++/CLI | |
|---|---|
public: virtual ImapMessage^ Add( Stream^ message, ImapFlags flags, DateTime internalDate ) | |
Parameters
- message
- A Stream object containing message data.
- flags
- An ImapFlags value representing the flags to set on the message.
- internalDate
- A System.Datetime representing the internal date to use for the message.
Return Value
An ImapMessage object representing the newly added message.| Exception | Description |
|---|---|
| Dart.PowerTCP.Mail.ProtocolException | Bad IMAP protocol response received from server. |
| System.Net.Sockets.SocketException | The requested address is not valid in its context. |
The following example demonstrates some of the methods of MailboxCollection.
| Visual Basic | Copy Code |
|---|---|
Private Sub MailboxCollectionDemo() ' Login Imap1.Login(Server, User, Pass) ' Create a test mailbox Imap1.Mailboxes.Add("MyNewMailbox") ' Get the name into a short variable name for less typing Dim Box As New Mailbox = imap1.Mailboxes("MyNewMailbox") ' Create a message from a message stored on file. Dim Msg as new MessageStream(New FileStream("C:\mymsg.txt", FileMode.Open)) ' Add a new message with flags and an internal date Dim InternalDate As New System.DateTime(2000, 1, 1) ImapMessage ImapMsg = Box.Messages.Add(Msg, ImapFlags.Flagged, internalDate); ' Remove the mailbox Imap1.Mailboxes.Remove(box) ' Logout imap1.Logout() End Sub | |
| C# | Copy Code |
|---|---|
private void MailboxCollectionDemo() { // Login imap1.Login(Server, User, Pass); // Create a test mailbox imap1.Mailboxes.Add("MyNewMailbox"); // Get the name into a short variable name for less typing Mailbox box = imap1.Mailboxes["MyNewMailbox"]; // Create a message from a message stored on file. MessageStream msg = new MessageStream(new FileStream("C:\\mymsg.txt", FileMode.Open)); // Add a new message with flags and an internal date System.DateTime internalDate = new System.DateTime(2000, 1, 1); ImapMessage imapMsg = box.Messages.Add(msg, ImapFlags.Flagged, internalDate); // Remove the mailbox imap1.Mailboxes.Remove(box); // Logout imap1.Logout(); } | |
Using the ImapMessageCollection.Add method causes an APPEND command to be sent to the IMAP server, adding the message contained in message to the mailbox represented by Imap.CurrentMailbox. Typically, message will be a MessageStream object, but can be any Stream object. flags determines which flags are set on the new message. internalDate sets the internal date (the date the message arrived) of the message on the server.
Target Platforms: Microsoft .NET Framework 2.0