PowerTCP Mail for .NET
Message Property
See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace > MessagePartEventArgs Class : Message Property




Gets the ImapMessage that contains the part.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Message As ImapMessage
Visual Basic (Usage)Copy Code
Dim instance As MessagePartEventArgs
Dim value As ImapMessage
 
value = instance.Message
C# 
public ImapMessage Message {get;}
Managed Extensions for C++ 
public: __property ImapMessage* get_Message();
C++/CLI 
public:
property ImapMessage^ Message {
   ImapMessage^ get();
}

Property Value

An ImapMessage object.

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

The MessagePartEventArgs.Message property returns the ImapMessage object representing the message that contains the part for which this event was raised.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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