| Visual Basic (Declaration) | |
|---|---|
Public Overloads Function Get( _ ByVal first As ImapMessage, _ ByVal last As ImapMessage, _ ByVal sections As ImapMessageSections _ ) As ImapMessage() | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Mailbox Dim first As ImapMessage Dim last As ImapMessage Dim sections As ImapMessageSections Dim value() As ImapMessage value = instance.Get(first, last, sections) | |
| C# | |
|---|---|
public ImapMessage[] Get( ImapMessage first, ImapMessage last, ImapMessageSections sections ) | |
| Managed Extensions for C++ | |
|---|---|
public: ImapMessage*[]* Get( ImapMessage* first, ImapMessage* last, ImapMessageSections sections ) | |
| C++/CLI | |
|---|---|
public: array<ImapMessage^>^ Get( ImapMessage^ first, ImapMessage^ last, ImapMessageSections sections ) | |
Parameters
- first
- An ImapMessage object representing the first message in the range to get.
- last
- An ImapMessage object representing the last message in the range to get.
- sections
- An ImapMessageSections value specifying the portion of the message to get.
Return Value
An array of ImapMessage objects representing the retrieved messages.| 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. |
| System.ArgumentOutOfRangeException | index was out of range |
| System.IndexOutOfRangeException | index was outside bounds of array |
| Dart.PowerTCP.Mail.InvalidParameterTypeException | Collection contains instances of wrong type of object |
The following example demonstrates retrieving partial messages.
| Visual Basic | Copy Code |
|---|---|
' Login to the server Imap1.Login(Server, User, Pass) ' Get the current mailbox in a short variable name so we don't have to type as much Dim Box As Mailbox = Imap1.CurrentMailbox Dim First As ImapMessage = Box.Messages(0) Dim Last As ImapMessage = Box.Messages(box.Messages.Count - 1) ' Get all message headers and messages sizes Box.Get(First, Last, ImapMessageSections.Header | ImapMessageSections.Size) ' Display Results. Dim Msg as ImapMessage For Each Msg in Box.Messages Debug.WriteLine("Size: " + Msg.Size) Debug.WriteLine("Subject: " + Msg.Message.Subject) Next ' Logout Imap1.Logout() | |
| C# | Copy Code |
|---|---|
// Login to the server imap1.Login(Server, User, Pass); // Get the current mailbox in a short variable name so we don't have to type as much Mailbox box = imap1.CurrentMailbox; ImapMessage first = box.Messages[0]; ImapMessage last = box.Messages[box.Messages.Count - 1]; // Get all message headers and messages sizes box.Get(first, last, ImapMessageSections.Header | ImapMessageSections.Size); // Display Results. foreach(ImapMessage msg in box.Messages) { Debug.WriteLine("Size: " + msg.Size); Debug.WriteLine("Subject: " + msg.Message.Subject); } // Logout imap1.Logout(); | |
The Mailbox.Get method retrieves some portion of all of the messages that are within the range specified by first and last. Both first and last must be located in the mailbox. This method uses the IMAP FETCH command to retrieve message content. The command uses the UIDs of the messages in the collection to retrieve content.
This method is useful for bulk operations. If you would like to retrieve only a single message, use the ImapMessage.Get method of the ImapMessage object.
Target Platforms: Microsoft .NET Framework 2.0