Files
2026-06-04 11:42:34 +02:00

186 lines
8.9 KiB
C#

using System;
using System.IO;
using System.Net.Mime;
using System.Text;
namespace System.Net.Mail
{
/// <summary>Represents an embedded external resource in an email attachment, such as an image in an HTML attachment.</summary>
// Token: 0x0200013C RID: 316
public class LinkedResource : AttachmentBase
{
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.LinkedResource" /> using the specified file name.</summary>
/// <param name="fileName">The file name holding the content for this embedded resource.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="fileName" /> is null.</exception>
// Token: 0x06000ABC RID: 2748 RVA: 0x000203B4 File Offset: 0x0001E5B4
public LinkedResource(string fileName)
: base(fileName)
{
if (fileName == null)
{
throw new ArgumentNullException();
}
}
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.LinkedResource" /> with the specified file name and content type.</summary>
/// <param name="fileName">The file name that holds the content for this embedded resource.</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>
// Token: 0x06000ABD RID: 2749 RVA: 0x000203CC File Offset: 0x0001E5CC
public LinkedResource(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.LinkedResource" /> with the specified file name and media type.</summary>
/// <param name="fileName">The file name that holds the content for this embedded resource.</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>
// Token: 0x06000ABE RID: 2750 RVA: 0x000203E4 File Offset: 0x0001E5E4
public LinkedResource(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.LinkedResource" /> using the supplied <see cref="T:System.IO.Stream" />.</summary>
/// <param name="contentStream">A stream that contains the content for this embedded resource.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="contentStream" /> is null.</exception>
// Token: 0x06000ABF RID: 2751 RVA: 0x000203FC File Offset: 0x0001E5FC
public LinkedResource(Stream contentStream)
: base(contentStream)
{
if (contentStream == null)
{
throw new ArgumentNullException();
}
}
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.LinkedResource" /> with the values supplied by <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 embedded resource.</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: 0x06000AC0 RID: 2752 RVA: 0x00020414 File Offset: 0x0001E614
public LinkedResource(Stream contentStream, global::System.Net.Mime.ContentType contentType)
: base(contentStream, contentType)
{
if (contentStream == null)
{
throw new ArgumentNullException();
}
}
/// <summary>Initializes a new instance of <see cref="T:System.Net.Mail.LinkedResource" /> with the specified <see cref="T:System.IO.Stream" /> and media type.</summary>
/// <param name="contentStream">A stream that contains the content for this embedded resource.</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: 0x06000AC1 RID: 2753 RVA: 0x0002042C File Offset: 0x0001E62C
public LinkedResource(Stream contentStream, string mediaType)
: base(contentStream, mediaType)
{
if (contentStream == null)
{
throw new ArgumentNullException();
}
}
/// <summary>Gets or sets a URI that the resource must match.</summary>
/// <returns>If <see cref="P:System.Net.Mail.LinkedResource.ContentLink" /> is a relative URI, the recipient of the message must resolve it.</returns>
// Token: 0x170002B4 RID: 692
// (get) Token: 0x06000AC2 RID: 2754 RVA: 0x00020444 File Offset: 0x0001E644
// (set) Token: 0x06000AC3 RID: 2755 RVA: 0x0002044C File Offset: 0x0001E64C
public global::System.Uri ContentLink
{
get
{
return this.contentLink;
}
set
{
this.contentLink = value;
}
}
/// <summary>Creates a <see cref="T:System.Net.Mail.LinkedResource" /> object from a string to be included in an email attachment as an embedded resource. The default media type is plain text, and the default content type is ASCII.</summary>
/// <returns>A <see cref="T:System.Net.Mail.LinkedResource" /> object that contains the embedded resource to be included in the email attachment.</returns>
/// <param name="content">A string that contains the embedded resource to be included in the email attachment.</param>
/// <exception cref="T:System.ArgumentNullException">The specified content string is null.</exception>
// Token: 0x06000AC4 RID: 2756 RVA: 0x00020458 File Offset: 0x0001E658
public static LinkedResource CreateLinkedResourceFromString(string content)
{
if (content == null)
{
throw new ArgumentNullException();
}
MemoryStream memoryStream = new MemoryStream(Encoding.Default.GetBytes(content));
return new LinkedResource(memoryStream)
{
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
};
}
/// <summary>Creates a <see cref="T:System.Net.Mail.LinkedResource" /> object from a string to be included in an email attachment as an embedded resource, with the specified content type, and media type as plain text.</summary>
/// <returns>A <see cref="T:System.Net.Mail.LinkedResource" /> object that contains the embedded resource to be included in the email attachment.</returns>
/// <param name="content">A string that contains the embedded resource to be included in the email attachment.</param>
/// <param name="contentType">The type of the content.</param>
/// <exception cref="T:System.ArgumentNullException">The specified content string is null.</exception>
// Token: 0x06000AC5 RID: 2757 RVA: 0x00020494 File Offset: 0x0001E694
public static LinkedResource CreateLinkedResourceFromString(string content, global::System.Net.Mime.ContentType contentType)
{
if (content == null)
{
throw new ArgumentNullException();
}
MemoryStream memoryStream = new MemoryStream(Encoding.Default.GetBytes(content));
return new LinkedResource(memoryStream, contentType)
{
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
};
}
/// <summary>Creates a <see cref="T:System.Net.Mail.LinkedResource" /> object from a string to be included in an email attachment as an embedded resource, with the specified content type, and media type.</summary>
/// <returns>A <see cref="T:System.Net.Mail.LinkedResource" /> object that contains the embedded resource to be included in the email attachment.</returns>
/// <param name="content">A string that contains the embedded resource to be included in the email attachment.</param>
/// <param name="contentEncoding">The type of the content.</param>
/// <param name="mediaType">The MIME media type of the content.</param>
/// <exception cref="T:System.ArgumentNullException">The specified content string is null.</exception>
// Token: 0x06000AC6 RID: 2758 RVA: 0x000204D0 File Offset: 0x0001E6D0
public static LinkedResource CreateLinkedResourceFromString(string content, Encoding contentEncoding, string mediaType)
{
if (content == null)
{
throw new ArgumentNullException();
}
MemoryStream memoryStream = new MemoryStream(contentEncoding.GetBytes(content));
return new LinkedResource(memoryStream, mediaType)
{
TransferEncoding = global::System.Net.Mime.TransferEncoding.QuotedPrintable
};
}
// Token: 0x04000B06 RID: 2822
private global::System.Uri contentLink;
}
}