C# Class Westwind.Utilities.InternetTools.SmtpClientNative

SMTP Wrapper around System.Net.Email.SmtpClient. Provided here mainly to provide compatibility with existing wwSmtp code and to provide a slightly more user friendly front end interface on a single object.
Inheritance: IDisposable
Mostra file Open project: RickStrahl/WestwindToolkit Class Usage Examples

Public Properties

Property Type Description
AlternateText string
AlternateTextContentType string
AttachmentList List
Attachments string
BCC string
CC string
CharacterEncoding string
ContentType string
Encoding System.Text.Encoding
Error bool
ErrorMessage string
HandleExceptions bool
Headers string>.Dictionary
LogFile string
MailServer string
Message string
Password string
Priority string
Recipient string
ReplyTo string
ReturnReceipt bool
SenderEmail string
SenderName string
ServerPort int
Subject string
Timeout int
UseSsl bool
UserAgent string
Username string

Protected Properties

Property Type Description
AlternateViews List

Public Methods

Method Description
AddAlternateView ( System.Net.Mail.AlternateView view ) : void

Adds a new Alternate view to the request. Passed from FoxPro which sets up this object.

AddHeader ( string headerName, string value ) : void

Adds an Smtp header to this email request. Headers are always cleared after a message has been sent or failed.

AddHeadersFromString ( string headers ) : void

Adds headers from a CR/LF separate string that has key:value header pairs defined.

Close ( ) : bool

Cleans up and closes the connection

Connect ( ) : bool

Starts a new SMTP session. Note this doesn't actually open a connection but just configures and sets up the SMTP session. The actual connection is opened only when a message is actually sent

Dispose ( ) : void
LoadSmtpClient ( ) : SmtpClient

Lets you load the actual SMTP client instance prior to use so you can manipulate the actual Smtp instance.

SendMail ( ) : bool

Fully self contained mail sending method. Sends an email message by connecting and disconnecting from the email server.

SendMailAsync ( ) : void

Run mail sending operation on a separate thread and asynchronously Operation does not return any information about completion.

SendMessage ( string recipient, string ccList, string bccList ) : bool

Sends an individual message. Allows sending several messages on the same SMTP session without having to reconnect each time. This version assigns default properties assigned from the main mail object and allows overriding only of recipients Call after Connect() has been called and call Close() to close the connection afterwards

Protected Methods

Method Description
GetMessage ( ) : MailMessage

Configures the message interface

LogString ( string message ) : void

Logs a message to the specified LogFile

SendMailRun ( ) : void

Private Methods

Method Description
AssignMailAddresses ( MailAddressCollection address, string recipients ) : void

Assigns mail addresses from a string or comma delimited string list. Facilitates

GetEmailFromFullAddress ( string fullEmail ) : string

Strips out just the email address from a full email address that might contain a display name in the format of: "Web Monitor" <[email protected]>

SetError ( string errorMessage ) : void

Internally used to set errors

Method Details

AddAlternateView() public method

Adds a new Alternate view to the request. Passed from FoxPro which sets up this object.
public AddAlternateView ( System.Net.Mail.AlternateView view ) : void
view System.Net.Mail.AlternateView
return void

AddHeader() public method

Adds an Smtp header to this email request. Headers are always cleared after a message has been sent or failed.
public AddHeader ( string headerName, string value ) : void
headerName string
value string
return void

AddHeadersFromString() public method

Adds headers from a CR/LF separate string that has key:value header pairs defined.
public AddHeadersFromString ( string headers ) : void
headers string
return void

Close() public method

Cleans up and closes the connection
public Close ( ) : bool
return bool

Connect() public method

Starts a new SMTP session. Note this doesn't actually open a connection but just configures and sets up the SMTP session. The actual connection is opened only when a message is actually sent
public Connect ( ) : bool
return bool

Dispose() public method

public Dispose ( ) : void
return void

GetMessage() protected method

Configures the message interface
protected GetMessage ( ) : MailMessage
return System.Net.Mail.MailMessage

LoadSmtpClient() public method

Lets you load the actual SMTP client instance prior to use so you can manipulate the actual Smtp instance.
public LoadSmtpClient ( ) : SmtpClient
return System.Net.Mail.SmtpClient

LogString() protected method

Logs a message to the specified LogFile
protected LogString ( string message ) : void
message string
return void

SendMail() public method

Fully self contained mail sending method. Sends an email message by connecting and disconnecting from the email server.
public SendMail ( ) : bool
return bool

SendMailAsync() public method

Run mail sending operation on a separate thread and asynchronously Operation does not return any information about completion.
public SendMailAsync ( ) : void
return void

SendMailRun() protected method

protected SendMailRun ( ) : void
return void

SendMessage() public method

Sends an individual message. Allows sending several messages on the same SMTP session without having to reconnect each time. This version assigns default properties assigned from the main mail object and allows overriding only of recipients Call after Connect() has been called and call Close() to close the connection afterwards
public SendMessage ( string recipient, string ccList, string bccList ) : bool
recipient string
ccList string
bccList string
return bool

Property Details

AlternateText public_oe property

public string AlternateText
return string

AlternateTextContentType public_oe property

The content type for the alternate
public string AlternateTextContentType
return string

AlternateViews protected_oe property

protected List AlternateViews
return List

AttachmentList public_oe property

List of attachment objects
public List AttachmentList
return List

Attachments public_oe property

Any attachments you'd like to send
public string Attachments
return string

BCC public_oe property

Blind Copy Recipients
public string BCC
return string

CC public_oe property

Carbon Copy Recipients
public string CC
return string

CharacterEncoding public_oe property

Character Encoding for the message.
public string CharacterEncoding
return string

ContentType public_oe property

The content type of the message. text/plain default or you can set to any other type like text/html
public string ContentType
return string

Encoding public_oe property

The character Encoding used to write the stream out to disk Defaults to the default Locale used on the server.
public Encoding,System.Text Encoding
return System.Text.Encoding

Error public_oe property

Error Flag set when an error occurs.
public bool Error
return bool

ErrorMessage public_oe property

An Error Message if the result is negative or Error is set to true;
public string ErrorMessage
return string

HandleExceptions public_oe property

Determines whether wwSMTP passes back errors as exceptions or whether it sets error properties. Right now only error properties work reliably.
public bool HandleExceptions
return bool

Headers public_oe property

SMTP headers for this email request
public Dictionary Headers
return string>.Dictionary

LogFile public_oe property

An optional file name that appends logging information for the TCP/IP messaging to the specified file.
public string LogFile
return string

MailServer public_oe property

Mail Server to send message through. Should be a domain name (mail.yourserver.net) or IP Address (211.123.123.123). You can also provide a port number as part of the string which will override the ServerPort (yourserver.net:211) Class wwSmtp
public string MailServer
return string

Message public_oe property

The body of the message.
public string Message
return string

Password public_oe property

Password to connect to the mail server.
public string Password
return string

Priority public_oe property

Determines the priority of the message
public string Priority
return string

Recipient public_oe property

Email address or addresses of the Recipient. Comma delimit multiple addresses. To have formatted names use "Rick Strahl" <[email protected]>
public string Recipient
return string

ReplyTo public_oe property

The ReplyTo address
public string ReplyTo
return string

ReturnReceipt public_oe property

Determines whether a return receipt is sent
public bool ReturnReceipt
return bool

SenderEmail public_oe property

Email address of the sender
public string SenderEmail
return string

SenderName public_oe property

Display name of the sender (optional)
public string SenderName
return string

ServerPort public_oe property

Port on the mail server to send through. Defaults to port 25.
public int ServerPort
return int

Subject public_oe property

Message Subject.
public string Subject
return string

Timeout public_oe property

Connection timeouts for the mail server in seconds. If this timeout is exceeded waiting for a connection or for receiving or sending data the request is aborted and fails.
public int Timeout
return int

UseSsl public_oe property

Use Tls Security
public bool UseSsl
return bool

UserAgent public_oe property

The user agent for the x-mailer
public string UserAgent
return string

Username public_oe property

Username to connect to the mail server.
public string Username
return string