PowerTCP Mail for .NET
MessagePartEventArgs Class
Members  Example  See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace : MessagePartEventArgs Class




Provides data for the Imap.EndGetPart event.

Object Model

MessagePartEventArgs ClassImapMessage Class

Syntax

Visual Basic (Declaration) 
Public Class MessagePartEventArgs 
   Inherits EndEventArgs
Visual Basic (Usage)Copy Code
Dim instance As MessagePartEventArgs
C# 
public class MessagePartEventArgs : EndEventArgs 
Managed Extensions for C++ 
public __gc class MessagePartEventArgs : public EndEventArgs 
C++/CLI 
public ref class MessagePartEventArgs : public EndEventArgs 

Example

The following example demonstrates asynchronously retrieving a part of a message.
Visual BasicCopy Code
Private Sub AsynchronousGetPartTest()
   ' Login 
   Imap1.Login(Server, User, Pass)

   ' Retrieve message outlines for INBOX.
   Imap1.CurrentMailbox.Get(Imap1.CurrentMailbox.Messages(0), Imap1.CurrentMailbox.Messages(Imap1.CurrentMailbox.Messages.Count - 1), ImapMessageSections.BodyStructure Or ImapMessageSections.Envelope)

   ' Find the first message with an attachment
   Dim Attach As MimeAttachmentStream
   Dim AttachMessage As ImapMessage
   Dim Msg As ImapMessage
   For Each Msg In Imap1.CurrentMailbox.Messages	
      If (Msg.Message.Attachments.Count > 0) Then
         Attach = Msg.Message.Attachments(0)
         AttachMessage = Msg
         Exit For
       End If
   Next
   
   ' Get the attachment. When complete the Imap.EndGetPart event will be raised
   AttachMessage.BeginGetPart(Attach, Nothing)
End Sub

Private Sub Imap1_EndGetPart(ByVal sender As Object, ByVal e As Dart.PowerTCP.Mail.MessagePartEventArgs) Handles Imap1.EndGetPart
   If e.Exception Is Nothing Then
      Debug.WriteLine("Part of message: " + e.Message.Id + " retrieved")
      Debug.WriteLine("Part Size = " & e.Part.Length)
   End If
End Sub
C#Copy Code
private void AsynchronousGetPartTest()
{
   // Login 
   imap1.Login(Server, User, Pass);

   // Retrieve message outlines for INBOX.
   imap1.CurrentMailbox.Get(imap1.CurrentMailbox.Messages[0], 
      imap1.CurrentMailbox.Messages[imap1.CurrentMailbox.Messages.Count - 1], 
      ImapMessageSections.BodyStructure | ImapMessageSections.Envelope);


   // Find the first message with an attachment
   MimeAttachmentStream attach = null;
   ImapMessage attachMessage = null;
   foreach(ImapMessage msg in imap1.CurrentMailbox.Messages)
   {
      if(msg.Message.Attachments.Count > 0)
      {
         // Save a reference to the attachment and message and break from the loop
         attach = (MimeAttachmentStream)msg.Message.Attachments[0];
         attachMessage = msg;
         break;
      }
   }
   
   // Get the attachment. When complete the Imap.EndGetPart event will be raised
   attachMessage.BeginGetPart(attach, null);
}

private void imap1_EndGetPart(object sender, Dart.PowerTCP.Mail.MessagePartEventArgs e)
{
   if(e.Exception == null)
   {
      Debug.WriteLine("Part of message: " + e.Message.Id + " retrieved");
      Debug.WriteLine("Part Size = " + e.Part.Length);
   }
}

Remarks

This class provides data for the Imap.EndGetPart event, which is raised upon completion of the ImapMessage.BeginGetPart method. The ImapMessage.BeginGetPart method is used to get message parts (such as attachments) from the IMAP server. The message part is accessible via the MessagePartEvent.Part property. The ImapMessage that contains the part is accessble via the MessagePartEvent.Message property.

Inheritance Hierarchy

System.Object
   System.EventArgs
      Dart.PowerTCP.Mail.EndEventArgs
         Dart.PowerTCP.Mail.MessagePartEventArgs

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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