225 lines
11 KiB
C#
225 lines
11 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Net.Mime;
|
|
using System.Text;
|
|
|
|
namespace System.Net.Mail
|
|
{
|
|
/// <summary>Represents the format to view an email message.</summary>
|
|
// Token: 0x02000135 RID: 309
|
|
public class AlternateView : AttachmentBase
|
|
{
|
|
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.AlternateView" /> with the specified file name.</summary>
|
|
/// <param name="fileName">The name of the file that contains the content for this alternate view.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="fileName" /> is null.</exception>
|
|
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
|
|
/// <exception cref="T:System.IO.IOException">An I/O error occurred, such as a disk error.</exception>
|
|
/// <exception cref="T:System.UnauthorizedAccessException">The access requested is not permitted by the operating system for the specified file handle, such as when access is Write or ReadWrite and the file handle is set for read-only access.</exception>
|
|
// Token: 0x06000A82 RID: 2690 RVA: 0x0001DA6C File Offset: 0x0001BC6C
|
|
public AlternateView(string fileName)
|
|
: base(fileName)
|
|
{
|
|
if (fileName == null)
|
|
{
|
|
throw new ArgumentNullException();
|
|
}
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.AlternateView" /> with the specified file name and content type.</summary>
|
|
/// <param name="fileName">The name of the file that contains the content for this alternate view.</param>
|
|
/// <param name="contentType">The type of the content.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="fileName" /> is null.</exception>
|
|
/// <exception cref="T:System.FormatException">
|
|
/// <paramref name="contentType" /> is not a valid value.</exception>
|
|
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
|
|
/// <exception cref="T:System.IO.IOException">An I/O error occurred, such as a disk error.</exception>
|
|
/// <exception cref="T:System.UnauthorizedAccessException">The access requested is not permitted by the operating system for the specified file handle, such as when access is Write or ReadWrite and the file handle is set for read-only access.</exception>
|
|
// Token: 0x06000A83 RID: 2691 RVA: 0x0001DA8C File Offset: 0x0001BC8C
|
|
public AlternateView(string fileName, global::System.Net.Mime.ContentType contentType)
|
|
: base(fileName, contentType)
|
|
{
|
|
if (fileName == null)
|
|
{
|
|
throw new ArgumentNullException();
|
|
}
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.AlternateView" /> with the specified file name and media type.</summary>
|
|
/// <param name="fileName">The name of the file that contains the content for this alternate view.</param>
|
|
/// <param name="mediaType">The MIME media type of the content.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="fileName" /> is null.</exception>
|
|
/// <exception cref="T:System.FormatException">
|
|
/// <paramref name="mediaType" /> is not a valid value.</exception>
|
|
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
|
|
/// <exception cref="T:System.IO.IOException">An I/O error occurred, such as a disk error.</exception>
|
|
/// <exception cref="T:System.UnauthorizedAccessException">The access requested is not permitted by the operating system for the specified file handle, such as when access is Write or ReadWrite and the file handle is set for read-only access.</exception>
|
|
// Token: 0x06000A84 RID: 2692 RVA: 0x0001DAB0 File Offset: 0x0001BCB0
|
|
public AlternateView(string fileName, string mediaType)
|
|
: base(fileName, mediaType)
|
|
{
|
|
if (fileName == null)
|
|
{
|
|
throw new ArgumentNullException();
|
|
}
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.AlternateView" /> with the specified <see cref="T:System.IO.Stream" />.</summary>
|
|
/// <param name="contentStream">A stream that contains the content for this view.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="contentStream" /> is null.</exception>
|
|
// Token: 0x06000A85 RID: 2693 RVA: 0x0001DAD4 File Offset: 0x0001BCD4
|
|
public AlternateView(Stream contentStream)
|
|
: base(contentStream)
|
|
{
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.AlternateView" /> with the specified <see cref="T:System.IO.Stream" /> and media type.</summary>
|
|
/// <param name="contentStream">A stream that contains the content for this attachment.</param>
|
|
/// <param name="mediaType">The MIME media type of the content.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="contentStream" /> is null.</exception>
|
|
/// <exception cref="T:System.FormatException">
|
|
/// <paramref name="mediaType" /> is not a valid value.</exception>
|
|
// Token: 0x06000A86 RID: 2694 RVA: 0x0001DAE8 File Offset: 0x0001BCE8
|
|
public AlternateView(Stream contentStream, string mediaType)
|
|
: base(contentStream, mediaType)
|
|
{
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.AlternateView" /> with the specified <see cref="T:System.IO.Stream" /> and <see cref="T:System.Net.Mime.ContentType" />.</summary>
|
|
/// <param name="contentStream">A stream that contains the content for this attachment.</param>
|
|
/// <param name="contentType">The type of the content.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="contentStream" /> is null.</exception>
|
|
/// <exception cref="T:System.FormatException">
|
|
/// <paramref name="contentType" /> is not a valid value.</exception>
|
|
// Token: 0x06000A87 RID: 2695 RVA: 0x0001DB00 File Offset: 0x0001BD00
|
|
public AlternateView(Stream contentStream, global::System.Net.Mime.ContentType contentType)
|
|
: base(contentStream, contentType)
|
|
{
|
|
}
|
|
|
|
/// <summary>Gets or sets the Base URI to use for resolving relative URIs in the <see cref="T:System.Net.Mail.AlternateView" />.</summary>
|
|
/// <returns>A <see cref="T:System.Uri" />.</returns>
|
|
// Token: 0x170002AB RID: 683
|
|
// (get) Token: 0x06000A88 RID: 2696 RVA: 0x0001DB18 File Offset: 0x0001BD18
|
|
// (set) Token: 0x06000A89 RID: 2697 RVA: 0x0001DB20 File Offset: 0x0001BD20
|
|
public global::System.Uri BaseUri
|
|
{
|
|
get
|
|
{
|
|
return this.baseUri;
|
|
}
|
|
set
|
|
{
|
|
this.baseUri = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the set of embedded resources referred to by this attachment.</summary>
|
|
/// <returns>A <see cref="T:System.Net.Mail.LinkedResourceCollection" /> object that stores the collection of linked resources to be sent as part of an e-mail message.</returns>
|
|
// Token: 0x170002AC RID: 684
|
|
// (get) Token: 0x06000A8A RID: 2698 RVA: 0x0001DB2C File Offset: 0x0001BD2C
|
|
public LinkedResourceCollection LinkedResources
|
|
{
|
|
get
|
|
{
|
|
return this.linkedResources;
|
|
}
|
|
}
|
|
|
|
/// <summary>Creates a <see cref="T:System.Net.Mail.AlternateView" /> of an email message using the content specified in a <see cref="System.String" />.</summary>
|
|
/// <returns>An <see cref="T:System.Net.Mail.AlternateView" /> object that represents an alternate view of an email message.</returns>
|
|
/// <param name="content">The <see cref="T:System.String" /> that contains the content of the email message.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="content" /> is null.</exception>
|
|
// Token: 0x06000A8B RID: 2699 RVA: 0x0001DB34 File Offset: 0x0001BD34
|
|
public static AlternateView CreateAlternateViewFromString(string content)
|
|
{
|
|
if (content == null)
|
|
{
|
|
throw new ArgumentNullException();
|
|
}
|
|
MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(content));
|
|
return new AlternateView(memoryStream)
|
|
{
|
|
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
|
|
};
|
|
}
|
|
|
|
/// <summary>Creates an <see cref="T:System.Net.Mail.AlternateView" /> of an email message using the content specified in a <see cref="System.String" /> and the specified MIME media type of the content.</summary>
|
|
/// <returns>An <see cref="T:System.Net.Mail.AlternateView" /> object that represents an alternate view of an email message.</returns>
|
|
/// <param name="content">A <see cref="T:System.String" /> that contains the content for this attachment.</param>
|
|
/// <param name="contentType">A <see cref="T:System.Net.Mime.ContentType" /> that describes the data in <paramref name="string" />.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="content" /> is null.</exception>
|
|
// Token: 0x06000A8C RID: 2700 RVA: 0x0001DB70 File Offset: 0x0001BD70
|
|
public static AlternateView CreateAlternateViewFromString(string content, global::System.Net.Mime.ContentType contentType)
|
|
{
|
|
if (content == null)
|
|
{
|
|
throw new ArgumentNullException("content");
|
|
}
|
|
Encoding encoding = ((contentType.CharSet == null) ? Encoding.UTF8 : Encoding.GetEncoding(contentType.CharSet));
|
|
MemoryStream memoryStream = new MemoryStream(encoding.GetBytes(content));
|
|
return new AlternateView(memoryStream, contentType)
|
|
{
|
|
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
|
|
};
|
|
}
|
|
|
|
/// <summary>Creates an <see cref="T:System.Net.Mail.AlternateView" /> of an email message using the content specified in a <see cref="System.String" />, the specified text encoding, and MIME media type of the content.</summary>
|
|
/// <returns>An <see cref="T:System.Net.Mail.AlternateView" /> object that represents an alternate view of an email message.</returns>
|
|
/// <param name="content">A <see cref="T:System.String" /> that contains the content for this attachment.</param>
|
|
/// <param name="contentEncoding">An <see cref="T:System.Text.Encoding" />. This value can be null.</param>
|
|
/// <param name="mediaType">The MIME media type of the content.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="content" /> is null.</exception>
|
|
// Token: 0x06000A8D RID: 2701 RVA: 0x0001DBCC File Offset: 0x0001BDCC
|
|
public static AlternateView CreateAlternateViewFromString(string content, Encoding encoding, string mediaType)
|
|
{
|
|
if (content == null)
|
|
{
|
|
throw new ArgumentNullException("content");
|
|
}
|
|
if (encoding == null)
|
|
{
|
|
encoding = Encoding.UTF8;
|
|
}
|
|
MemoryStream memoryStream = new MemoryStream(encoding.GetBytes(content));
|
|
return new AlternateView(memoryStream, new global::System.Net.Mime.ContentType
|
|
{
|
|
MediaType = mediaType,
|
|
CharSet = encoding.HeaderName
|
|
})
|
|
{
|
|
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
|
|
};
|
|
}
|
|
|
|
/// <summary>Releases the unmanaged resources used by the <see cref="T:System.Net.Mail.AlternateView" /> and optionally releases the managed resources. </summary>
|
|
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources. </param>
|
|
// Token: 0x06000A8E RID: 2702 RVA: 0x0001DC30 File Offset: 0x0001BE30
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
foreach (LinkedResource linkedResource in this.linkedResources)
|
|
{
|
|
linkedResource.Dispose();
|
|
}
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
// Token: 0x04000AF7 RID: 2807
|
|
private global::System.Uri baseUri;
|
|
|
|
// Token: 0x04000AF8 RID: 2808
|
|
private LinkedResourceCollection linkedResources = new LinkedResourceCollection();
|
|
}
|
|
}
|