| Visual Basic (Declaration) | |
|---|---|
Public ReadOnly Property Part As Stream | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As MessagePartEventArgs Dim value As Stream value = instance.Part | |
| C# | |
|---|---|
public Stream Part {get;} | |
| Managed Extensions for C++ | |
|---|---|
public: __property Stream* get_Part(); | |
Property Value
A System.IO.Stream object containing part data.The following example demonstrates asynchronously retrieving a part of a message.
| Visual Basic | Copy 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); } } | |
The MessagePartEventArgs.Part property returns a System.IO.Stream object containing the part data. Cast this value into the appropriate stream type. For example, if an attachment was retrieved, you would cast MessagePartEventArgs.Part into a MimeAttachmentStream object.
Target Platforms: Microsoft .NET Framework 2.0
Copy Code