PowerTCP Mail for .NET
Get(ImapMessage,ImapMessage,ImapMessageSections) Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Mailbox Class > Get Method : Get(ImapMessage,ImapMessage,ImapMessageSections) Method




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.
Retrieves a specified portion of the messages contained in the specified range.

Syntax

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)
Managed Extensions for C++ 
public: 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.

Exceptions

ExceptionDescription
Dart.PowerTCP.Mail.ProtocolExceptionBad IMAP protocol response received from server.
System.Net.Sockets.SocketExceptionThe requested address is not valid in its context.
System.ArgumentOutOfRangeExceptionindex was out of range
System.IndexOutOfRangeExceptionindex was outside bounds of array
Dart.PowerTCP.Mail.InvalidParameterTypeExceptionCollection contains instances of wrong type of object

Example

The following example demonstrates retrieving partial messages.
Visual BasicCopy 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();

Remarks

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.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.