33 if (
string.IsNullOrEmpty(contentID))
37 if (contentID.Length >= 2 && contentID[0] ==
'<' && contentID[contentID.Length - 1] ==
'>')
39 return contentID.Substring(1, contentID.Length - 2);
46 if (
string.IsNullOrEmpty(
value))
48 _part.ContentID =
null;
55 _part.ContentID =
"<" +
value +
">";
67 _part.ContentType =
value;
79 _part.TransferEncoding =
value;
95 _part.ContentLocation = ((
value ==
null) ?
null : (value.IsAbsoluteUri ? value.AbsoluteUri :
value.OriginalString));
145 protected virtual void Dispose(
bool disposing)
156 if (fileName ==
null)
160 if (fileName.Length == 0)
170 if (fileName ==
null)
174 if (fileName.Length == 0)
215 if (
string.IsNullOrEmpty(mediaType))
217 mediaType =
"text/plain";
223 if (
text.Length == 0 ||
offset >= mediaType.Length || mediaType[
offset++] !=
'/')
228 if (
text.Length == 0 ||
offset < mediaType.Length)
238 if (encoding ==
null)
242 contentType.CharSet = encoding.
BodyName;
void SetContentFromString(string content, ContentType contentType)
AttachmentBase(string fileName, string? mediaType)
AttachmentBase(Stream contentStream, string? mediaType)
AttachmentBase(Stream contentStream, ContentType? contentType)
virtual void Dispose(bool disposing)
void SetContentFromFile(string fileName, ContentType contentType)
virtual void PrepareForSending(bool allowUnicode)
AttachmentBase(string fileName)
static readonly char[] s_contentCIDInvalidChars
AttachmentBase(Stream contentStream, string name, string mediaType)
void SetContentFromString(string content, Encoding encoding, string mediaType)
AttachmentBase(string fileName, ContentType? contentType)
void SetContentFromFile(string fileName, string mediaType)
AttachmentBase(Stream contentStream)
static string ReadToken(string data, ref int offset, StringBuilder builder)
static bool IsAscii(string value, bool permitCROrLF)
static bool ShouldUseBase64Encoding(Encoding encoding)
TransferEncoding TransferEncoding
void SetContent(Stream stream)
static string Format(string resourceFormat, object p1)
static string MailHeaderInvalidCID
static string MediaTypeInvalid
static string net_emptystringcall
static Encoding GetEncoding(int codepage)
virtual byte[] GetBytes(char[] chars)
static bool TryCreate([NotNullWhen(true)] string? uriString, UriKind uriKind, [NotNullWhen(true)] out Uri? result)