Method CreateFromText
CreateFromText(string, string)
Creates a new Attachment instance from a plain-text string.
public static Attachment CreateFromText(string text, string name)
Parameters
text
stringThe text content to encode into the attachment. This will be converted to UTF-8 bytes.
name
stringThe file name to assign to the attachment. Used to infer its MIME type (e.g. “.txt” → text/plain).
Returns
- Attachment
A new Attachment initialized with the UTF-8 bytes of
text
and the specifiedname
.
Exceptions
- ArgumentNullException
Thrown if
text
orname
isnull
.