MailMessageHasAttachments Property |
Indicates if the message has any attachments.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool HasAttachments { get; }
Public ReadOnly Property HasAttachments As Boolean
Get
Property Value
Type:
Booleantrue if the message has at least one attachment; otherwise,
false.
Remarks
If only the headers of the message were received from the mail server, this property may not be 100% accurate.
The developer should download the entire message to be sure if it really has any attachments or not.
Examples This sample downloads the message from the specified POP3 account and displays the number of
the message attachments.
using System;
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;
class Sample
{
static void Main(string[] args)
{
MailMessage msg = Pop3.QuickDownloadMessage("pop3.mail.com", "kathy1981", "password", 1);
if (msg.HasAttachments)
{
Console.WriteLine("This message has " + msg.Attachments.Count.ToString() + " attachments");
}
else
{
Console.WriteLine("This message does not have any attachments");
}
}
}
Imports System
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As MailMessage = Pop3.QuickDownloadMessage("pop3.mail.com", "kathy1981", "password", 1)
If msg.HasAttachments Then
Console.WriteLine("This message has " & msg.Attachments.Count.ToString() & " attachments")
Else
Console.WriteLine("This message does not have any attachments")
End If
End Sub
End Module
See Also