GemBox.Email
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    Attachment Class

    Namespace:
    GemBox.Email
    Assembly:
    GemBox.Email.dll

    Represents a mail message attachment.

    • C#
    • VB.NET
    public sealed class Attachment
    Public NotInheritable Class Attachment
    Inheritance:
    System.Object
    Attachment

    Constructors

    Attachment(MediaType, Byte[])

    Initializes a new instance of the Attachment class with specified content type and content.

    • C#
    • VB.NET
    public Attachment(MediaType contentType, byte[] content)
    Public Sub New(contentType As MediaType, content As Byte())
    Parameters
    contentType
    MediaType

    The Content-Type header value.

    content
    System.Byte[]

    The content.

    Exceptions
    System.ArgumentNullException

    Content is null.

    Attachment(MediaType, Stream)

    Initializes a new instance of the Attachment class with specified content type and content.

    • C#
    • VB.NET
    public Attachment(MediaType contentType, Stream content)
    Public Sub New(contentType As MediaType, content As Stream)
    Parameters
    contentType
    MediaType

    The Content-Type header value.

    content
    System.IO.Stream

    The content.

    Exceptions
    System.ArgumentException

    Content is null or empty.

    Attachment(MediaType, Stream, String)

    Initializes a new instance of the Attachment class with specified content type, content and file name.

    • C#
    • VB.NET
    public Attachment(MediaType contentType, Stream content, string fileName)
    Public Sub New(contentType As MediaType, content As Stream, fileName As String)
    Parameters
    contentType
    MediaType

    The Content-Type header value.

    content
    System.IO.Stream

    The content.

    fileName
    System.String

    File name.

    Exceptions
    System.ArgumentException

    Content is null or empty.

    Attachment(Stream, String)

    Initializes a new instance of the Attachment class with specified content and file name.

    • C#
    • VB.NET
    public Attachment(Stream content, string fileName)
    Public Sub New(content As Stream, fileName As String)
    Parameters
    content
    System.IO.Stream

    The content.

    fileName
    System.String

    File name.

    Exceptions
    System.ArgumentException

    Content is null or empty.

    Attachment(String)

    Initializes a new instance of the Attachment class from specified file.

    • C#
    • VB.NET
    public Attachment(string filePath)
    Public Sub New(filePath As String)
    Parameters
    filePath
    System.String

    A relative or absolute path for the file.

    Exceptions
    System.ArgumentException

    File path is null or empty.

    Properties

    ContentId

    Gets or sets the attachment content id.

    • C#
    • VB.NET
    public string ContentId { get; set; }
    Public Property ContentId As String
    Property Value
    System.String

    The attachment content id.

    Data

    Gets the attachment data stream.

    • C#
    • VB.NET
    public MemoryStream Data { get; }
    Public ReadOnly Property Data As MemoryStream
    Property Value
    System.IO.MemoryStream

    The attachment data stream.

    DispositionType

    Gets the attachment content disposition type.

    • C#
    • VB.NET
    public ContentDispositionType DispositionType { get; }
    Public ReadOnly Property DispositionType As ContentDispositionType
    Property Value
    ContentDispositionType

    The attachment content disposition type.

    Exceptions
    System.ArgumentException

    Content disposition type cannot be set to Unknown.

    FileName

    Gets the file name.

    • C#
    • VB.NET
    public string FileName { get; }
    Public ReadOnly Property FileName As String
    Property Value
    System.String

    The file name, if defined; otherwise, null.

    MimeEntity

    Gets the underlying MIME entity.

    • C#
    • VB.NET
    public ContentEntity MimeEntity { get; }
    Public ReadOnly Property MimeEntity As ContentEntity
    Property Value
    ContentEntity

    The underlying MIME entity.

    Size

    Gets the data size.

    • C#
    • VB.NET
    public int? Size { get; }
    Public ReadOnly Property Size As Integer?
    Property Value
    System.Nullable<System.Int32>

    The data size, if defined; otherwise, null.

    Methods

    GetTaggedProperty(PropertyTag)

    Returns the value stored into a specific tagged property. Works only for messages loaded from MSG files.

    • C#
    • VB.NET
    public object GetTaggedProperty(PropertyTag tag)
    Public Function GetTaggedProperty(tag As PropertyTag) As Object
    Parameters
    tag
    PropertyTag

    The ID of the tag from which to retrieve the value.

    Returns
    System.Object

    An System.Object containing the value of the specified tag or null if the property was not found.

    Save(Stream)

    Saves the attachment into the specified stream.

    • C#
    • VB.NET
    public void Save(Stream stream)
    Public Sub Save(stream As Stream)
    Parameters
    stream
    System.IO.Stream

    The stream in which to save the attachment.

    Save(String)

    Saves the attachment into the specified path.

    • C#
    • VB.NET
    public void Save(string path)
    Public Sub Save(path As String)
    Parameters
    path
    System.String

    The path to which to save the attachment.

    SetTaggedProperty(PropertyTag, Object)

    Explicitly sets the value of a tagged property. Works only for messages that will be saved to a MSG file. Items set with this method will be written when saving the message to .msg, overwriting any other properties normally set by other members, which can cause errors.
    For example, setting GemBox.Email.Msg.Properties.PropertyTag.AttachDataBinary will override the attachment's binary content regardless of what is on Data.

    • C#
    • VB.NET
    public void SetTaggedProperty(PropertyTag tag, object value)
    Public Sub SetTaggedProperty(tag As PropertyTag, value As Object)
    Parameters
    tag
    PropertyTag

    The ID of the tag to set.

    value
    System.Object

    The value of the tagged property.

    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.