MailHelper
Provides helper methods to send emails and to manage mail attachments.
Métodos
public static MailMessage AddHtml(MailMessage message, string bodyHtml)
result = MailHelper.AddHtml(message, bodyHtml)
Adds an HTML body alternate view to the specified MailMessage.
- message
- The mail message to add the HTML body to.
- bodyHtml
- The HTML string representing the body content.
Retorna: The updated MailMessage instance.
public static MailMessage AddPlain(MailMessage message, string bodyPlain)
result = MailHelper.AddPlain(message, bodyPlain)
Adds a plain text body alternate view to the specified MailMessage.
- message
- The mail message to add the plain text body to.
- bodyPlain
- The plain text string representing the body content.
Retorna: The updated MailMessage instance.
public static MailMessage Attach(MailMessage message, string fileName, Stream fileBody)
result = MailHelper.Attach(message, fileName, fileBody)
Attaches a file to the specified MailMessage using the provided stream.
- message
- The mail message to attach the file to.
- fileName
- The name of the file to attach.
- fileBody
- The stream that represents the file content.
Retorna: The updated MailMessage instance.
public static Attachment CreateAttachment(Stream attachmentFile, string displayName, TransferEncoding transferEncoding)
result = MailHelper.CreateAttachment(attachmentFile, displayName, transferEncoding)
Creates an Attachment from the provided stream and display name, with specified transfer encoding.
- attachmentFile
- The stream containing the attachment file.
- displayName
- The display name for the attachment.
- transferEncoding
- The transfer encoding to use. Defaults to Base64.
Retorna: A new instance of Attachment configured with the provided parameters.
public static bool IsEmailValid(string email)
result = MailHelper.IsEmailValid(email)
Validates whether the specified email address string is in a correct format.
- The email address string to validate.
Retorna: true if the email format is valid; otherwise, false.
public static Attachment ToAttachment(string fileName, Stream fileBody)
result = MailHelper.ToAttachment(fileName, fileBody)
Creates a new Attachment from the specified file name and file stream.
- fileName
- The name of the file for the attachment.
- fileBody
- The stream representing the attachment content.
Retorna: A new instance of Attachment.