Method CreateFromText
CreateFromText(string, string)
Creates a new Attachment from a plain-text string.
public static Attachment CreateFromText(string text, string name)
Parameters
textstringThe textual content to encode using UTF-8.
namestringThe file name to associate with the content (for example, ending with
.txtor.md). The extension is used to pick betweentext/plainandtext/markdown; anything else defaults totext/plain.
Returns
- Attachment
An Attachment carrying the provided text content.
Remarks
This method performs no I/O operations and therefore does not require an asynchronous variant.
Exceptions
- ArgumentNullException
Thrown if
textornameisnull.