using System;
using System.IO;
using System.Net.Mime;
using System.Text;
namespace System.Net.Mail
{
/// Represents an attachment to an e-mail.
// Token: 0x02000137 RID: 311
public class Attachment : AttachmentBase
{
/// Initializes a new instance of the class with the specified content string.
/// A that contains a file path to use to create this attachment.
///
/// is null.
///
/// is empty.
// Token: 0x06000A95 RID: 2709 RVA: 0x0001DCD8 File Offset: 0x0001BED8
public Attachment(string fileName)
: base(fileName)
{
this.InitName(fileName);
}
/// Initializes a new instance of the class with the specified content string and MIME type information.
/// A that contains the content for this attachment.
/// A that contains the MIME Content-Header information for this attachment. This value can be null.
///
/// is null.
///
/// is not in the correct format.
// Token: 0x06000A96 RID: 2710 RVA: 0x0001DCF4 File Offset: 0x0001BEF4
public Attachment(string fileName, string mediaType)
: base(fileName, mediaType)
{
this.InitName(fileName);
}
/// Initializes a new instance of the class with the specified content string and .
/// A that contains a file path to use to create this attachment.
/// A that describes the data in .
///
/// is null.
///
/// is not in the correct format.
// Token: 0x06000A97 RID: 2711 RVA: 0x0001DD10 File Offset: 0x0001BF10
public Attachment(string fileName, global::System.Net.Mime.ContentType contentType)
: base(fileName, contentType)
{
this.InitName(fileName);
}
/// Initializes a new instance of the class with the specified stream and content type.
/// A readable that contains the content for this attachment.
/// A that describes the data in .
///
/// is null.-or- is null.
// Token: 0x06000A98 RID: 2712 RVA: 0x0001DD2C File Offset: 0x0001BF2C
public Attachment(Stream contentStream, global::System.Net.Mime.ContentType contentType)
: base(contentStream, contentType)
{
}
/// Initializes a new instance of the class with the specified stream and name.
/// A readable that contains the content for this attachment.
/// A that contains the value for the property of the associated with this attachment. This value can be null.
///
/// is null.
// Token: 0x06000A99 RID: 2713 RVA: 0x0001DD44 File Offset: 0x0001BF44
public Attachment(Stream contentStream, string name)
: base(contentStream)
{
this.Name = name;
}
/// Initializes a new instance of the class with the specified stream, name, and MIME type information.
/// A readable that contains the content for this attachment.
/// A that contains the value for the property of the associated with this attachment. This value can be null.
/// A that contains the MIME Content-Header information for this attachment. This value can be null.
///
/// is null.
///
/// is not in the correct format.
// Token: 0x06000A9A RID: 2714 RVA: 0x0001DD60 File Offset: 0x0001BF60
public Attachment(Stream contentStream, string name, string mediaType)
: base(contentStream, mediaType)
{
this.Name = name;
}
/// Gets the MIME content disposition for this attachment.
/// A that provides the presentation information for this attachment.
// Token: 0x170002AD RID: 685
// (get) Token: 0x06000A9B RID: 2715 RVA: 0x0001DD7C File Offset: 0x0001BF7C
public global::System.Net.Mime.ContentDisposition ContentDisposition
{
get
{
return this.contentDisposition;
}
}
/// Gets or sets the MIME content type name value in the content type associated with this attachment.
/// A that contains the value for the content type represented by the property.
/// The value specified for a set operation is null.
/// The value specified for a set operation is ("").
// Token: 0x170002AE RID: 686
// (get) Token: 0x06000A9C RID: 2716 RVA: 0x0001DD84 File Offset: 0x0001BF84
// (set) Token: 0x06000A9D RID: 2717 RVA: 0x0001DD94 File Offset: 0x0001BF94
public string Name
{
get
{
return base.ContentType.Name;
}
set
{
base.ContentType.Name = value;
}
}
/// Specifies the encoding for the .
/// An value that specifies the type of name encoding. The default value is determined from the name of the attachment.
// Token: 0x170002AF RID: 687
// (get) Token: 0x06000A9E RID: 2718 RVA: 0x0001DDA4 File Offset: 0x0001BFA4
// (set) Token: 0x06000A9F RID: 2719 RVA: 0x0001DDAC File Offset: 0x0001BFAC
public Encoding NameEncoding
{
get
{
return this.nameEncoding;
}
set
{
this.nameEncoding = value;
}
}
/// Creates a mail attachment using the content from the specified string, and the specified .
/// An object of type .
/// A that contains the content for this attachment.
/// A object that represents the Multipurpose Internet Mail Exchange (MIME) protocol Content-Type header to be used.
// Token: 0x06000AA0 RID: 2720 RVA: 0x0001DDB8 File Offset: 0x0001BFB8
public static Attachment CreateAttachmentFromString(string content, global::System.Net.Mime.ContentType contentType)
{
if (content == null)
{
throw new ArgumentNullException("content");
}
MemoryStream memoryStream = new MemoryStream();
StreamWriter streamWriter = new StreamWriter(memoryStream);
streamWriter.Write(content);
streamWriter.Flush();
memoryStream.Position = 0L;
return new Attachment(memoryStream, contentType)
{
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
};
}
/// Creates a mail attachment using the content from the specified string, and the specified MIME content type name.
/// An object of type .
/// A that contains the content for this attachment.
/// The MIME content type name value in the content type associated with this attachment.
// Token: 0x06000AA1 RID: 2721 RVA: 0x0001DE08 File Offset: 0x0001C008
public static Attachment CreateAttachmentFromString(string content, string name)
{
if (content == null)
{
throw new ArgumentNullException("content");
}
MemoryStream memoryStream = new MemoryStream();
StreamWriter streamWriter = new StreamWriter(memoryStream);
streamWriter.Write(content);
streamWriter.Flush();
memoryStream.Position = 0L;
return new Attachment(memoryStream, new global::System.Net.Mime.ContentType("text/plain"))
{
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable,
Name = name
};
}
/// Creates a mail attachment using the content from the specified string, the specified MIME content type name, character encoding, and MIME header information for the attachment.
/// An object of type .
/// A that contains the content for this attachment.
/// The MIME content type name value in the content type associated with this attachment.
/// An . This value can be null.
/// A that contains the MIME Content-Header information for this attachment. This value can be null.
// Token: 0x06000AA2 RID: 2722 RVA: 0x0001DE68 File Offset: 0x0001C068
public static Attachment CreateAttachmentFromString(string content, string name, Encoding contentEncoding, string mediaType)
{
if (content == null)
{
throw new ArgumentNullException("content");
}
MemoryStream memoryStream = new MemoryStream();
StreamWriter streamWriter = new StreamWriter(memoryStream, contentEncoding);
streamWriter.Write(content);
streamWriter.Flush();
memoryStream.Position = 0L;
return new Attachment(memoryStream, name, mediaType)
{
TransferEncoding = global::System.Net.Mime.ContentType.GuessTransferEncoding(contentEncoding),
ContentType =
{
CharSet = streamWriter.Encoding.BodyName
}
};
}
// Token: 0x06000AA3 RID: 2723 RVA: 0x0001DED8 File Offset: 0x0001C0D8
private void InitName(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
this.Name = Path.GetFileName(fileName);
}
// Token: 0x04000AF9 RID: 2809
private global::System.Net.Mime.ContentDisposition contentDisposition = new global::System.Net.Mime.ContentDisposition();
// Token: 0x04000AFA RID: 2810
private Encoding nameEncoding;
}
}