MailMessage.Save

Save(string)

Saves the message to a file in EML format, whatever the file extension.

public virtual void Save(string fileName)
ParameterTypeDescription
fileNameStringThe path of the file to write.

See Also


Save(string, SaveOptions)

Saves the message to a file in the format selected by the options.

public virtual void Save(string fileName, SaveOptions options)
ParameterTypeDescription
fileNameStringThe path of the file to write.
optionsSaveOptionsThe options; their class selects the format, such as MsgSaveOptions or MhtSaveOptions.

Examples

The following example shows how to save an email message as HTML with embedded images.

[C#]

var fileName = "EmailWithAttachEmbedded.eml";
var eml = MailMessage.Load(fileName);

var options = new HtmlSaveOptions()
{
    ResourceRenderingMode = ResourceRenderingMode.EmbedIntoHtml
};

eml.Save($"{fileName}.html", options);

[Visual Basic]

Dim fileName = "EmailWithAttachEmbedded.eml"
Dim eml = MailMessage.Load(fileName)

Dim options = New HtmlSaveOptions() With {
    .ResourceRenderingMode = ResourceRenderingMode.EmbedIntoHtml
}

eml.Save($"{fileName}.html", options)

See Also


Save(Stream, SaveOptions)

Saves the message to a stream in the format selected by the options.

public virtual void Save(Stream stream, SaveOptions options)
ParameterTypeDescription
streamStreamThe stream to write to.
optionsSaveOptionsThe options; their class selects the format, such as MsgSaveOptions or MhtSaveOptions.

See Also


Save(Stream)

Saves the message to a stream in EML format.

public virtual void Save(Stream stream)
ParameterTypeDescription
streamStreamThe stream to write to.

See Also