MailMessage.Save

Save(string)

Save message as a file

public virtual void Save(string fileName)
ParameterTypeDescription
fileNameStringName of a file to save message.

See Also


Save(string, SaveOptions)

Save message as a file with additional options.

public virtual void Save(string fileName, SaveOptions options)
ParameterTypeDescription
fileNameStringStream into which message is saved.
optionsSaveOptionsAdditional options for savingSaveOptions.

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)

Save message as a stream with additional options.

public virtual void Save(Stream stream, SaveOptions options)
ParameterTypeDescription
streamStreamStream into which message is saved.
optionsSaveOptionsAdditional options for savingSaveOptions.

See Also


Save(Stream)

Save message as a stream

public virtual void Save(Stream stream)
ParameterTypeDescription
streamStreamStream into which message is saved

See Also