Click or drag to resize

Mail Class

A wrapper class to the MailMessage class that simplifies sending mail messages.
Inheritance Hierarchy
SystemObject
  GSF.Net.SmtpMail

Namespace: GSF.Net.Smtp
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.218-beta+101eee949414e414795e55a6e73d88938f0177b8
Syntax
public class Mail : IDisposable
View Source

The Mail type exposes the following members.

Constructors
 NameDescription
Public methodMail Initializes a new instance of the Mail class.
Public methodMail(String) Initializes a new instance of the Mail class.
Public methodMail(String, String) Initializes a new instance of the Mail class.
Public methodMail(String, String, String) Initializes a new instance of the Mail class.
Top
Properties
 NameDescription
Public propertyAttachments Gets or sets the comma-separated or semicolon-separated list of file names to be attached to the Mail message.
Public propertyBccRecipients Gets or sets the comma-separated or semicolon-separated e-mail address list of the Mail message blank carbon copy (BCC) recipients.
Public propertyBody Gets or sets the body of the Mail message.
Public propertyCcRecipients Gets or sets the comma-separated or semicolon-separated e-mail address list of the Mail message carbon copy (CC) recipients.
Public propertyClient Gets the SmtpClient object used for sending the Mail message.
Public propertyEnableSSL Gets or sets the flag that determines whether to use SSL when communicating with the SMTP server.
Public propertyFrom Gets or sets the e-mail address of the Mail message sender.
Public propertyIsBodyHtml Gets or sets a boolean value that indicating whether the Mail message Body is to be formatted as HTML.
Public propertyPassword Gets or sets the password used to authenticate to the SMTP server.
Public propertySecurePassword Gets or sets the password used to authenticate to the SMTP server.
Public propertySmtpServer Gets or sets the name or IP address of the SMTP server to be used for sending the Mail message.
Public propertySubject Gets or sets the subject of the Mail message.
Public propertyToRecipients Gets or sets the comma-separated or semicolon-separated e-mail address list of the Mail message recipients.
Public propertyUsername Gets or sets the username used to authenticate to the SMTP server.
Top
Methods
 NameDescription
Public methodDispose Releases all the resources used by the Mail object.
Protected methodDispose(Boolean) Releases the unmanaged resources used by the Mail object and optionally releases the managed resources.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalize Releases the unmanaged resources before the Mail object is reclaimed by GC.
(Overrides ObjectFinalize)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodSend Send the Mail message with Attachments to the ToRecipients, CcRecipients and BccRecipients using the specified SmtpServer.
Public methodStatic memberSend(String, String, String, String, Boolean, String) Sends a Mail message.
Public methodStatic memberSend(String, String, String, String, Boolean, String, String) Sends a Mail message.
Public methodStatic memberSend(String, String, String, String, Boolean, String, String, SecureString) Sends a secure Mail message.
Public methodStatic memberSend(String, String, String, String, Boolean, String, String, String) Sends a secure Mail message.
Public methodStatic memberSend(String, String, String, String, String, String, Boolean, String) Sends a Mail message.
Public methodStatic memberSend(String, String, String, String, Boolean, String, String, SecureString, Boolean) Sends a secure Mail message.
Public methodStatic memberSend(String, String, String, String, Boolean, String, String, String, Boolean) Sends a secure Mail message.
Public methodStatic memberSend(String, String, String, String, String, String, Boolean, String, String) Sends a Mail message.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Fields
 NameDescription
Public fieldStatic memberDefaultSmtpServer Default SmtpServer to be used if one is not specified.
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Example
This example shows how to send an email message with attachment:
C#
using System;
using GSF.Net.Smtp;

class Program
{
    static void Main(string[] args)
    {
        Mail email = new Mail("sender@email.com", "recipient@email.com", "smtp.email.com");
        email.Subject = "Test Message";
        email.Body = "This is a test message.";
        email.IsBodyHtml = true;
        email.Attachments = @"c:\attachment.txt";
        email.Send();
        email.Dispose();

        Console.ReadLine();
    }
}
See Also