| Ferrysoft | SMTP Module | ||||||||||||||||||||||||||||||||||||||||
| Home Products Support Development Contact | |||||||||||||||||||||||||||||||||||||||||
|
SMTP Module Overview The Ferrysoft SMTP Module is a client class to send emails to an SMTP server. The SMTP Module is provided in source code form (Visual Basic 2005/2008 compatible and Visual C# 2005/2008 compatible). It is intended for developers, to incorporate into their own applications, in order to provide SMTP client support to the application. The module can be used, royalty-free, by any individual or organisation that purchases the module. As the module is provided in source code form, it can be modified as necessary after purchase, provided that any derived module is not distributed, in source code form, to a third party. The module can be incorporated into a commercial product and sold to third parties, in compiled format, provided that the purpose of the commercial product is not simply to act as a wrapper for the SMTP Module. Buy It
The SMTP Module is priced in Pounds Sterling (GBP), US Dollars (USD) and Euros (EUR).
Summary The Ferrysoft SMTP Module is a wrapper class for the System.Net.Mail namespace. It has the following advantages over using the System.Net.Mail namespace natively:
Summary of methods provided by the class The methods provided by the class are described in the following table.
Compose methods Syntax Visual Basic Friend Overloads Sub Compose( _ ByVal MessageSubject As String, _ ByVal MessageBody As String) Friend Overloads Sub Compose( _ ByVal MessageSubject As String, _ ByVal MessageBody As String, _ ByVal MessageSubjectEncoding As System.Text.Encoding, _ ByVal MessageBodyEncoding As System.Text.Encoding, _ ByVal MessageIsBodyHtml As Boolean, _ ByVal MessagePriority As System.Net.Mail.MailPriority, _ ByVal MessageDeliveryNotificationOptions As _ System.Net.Mail.DeliveryNotificationOptions) C# internal void Compose( string MessageSubject, string MessageBody) internal void Compose( string MessageSubject, string MessageBody, System.Text.Encoding MessageSubjectEncoding, System.Text.Encoding MessageBodyEncoding, bool MessageIsBodyHtml, System.Net.Mail.MailPriority MessagePriority, System.Net.Mail.DeliveryNotificationOptions MessageDeliveryNotificationOptions) Parameters
SetFrom / SetSender / SetReplyTo methods Syntax Visual Basic Friend Overloads Sub SetFrom( _ ByVal EmailAddress As String) Friend Overloads Sub SetFrom( _ ByVal EmailAddress As String, _ ByVal EmailName As String) Friend Overloads Sub SetSender( _ ByVal EmailAddress As String) Friend Overloads Sub SetSender( _ ByVal EmailAddress As String, _ ByVal EmailName As String) Friend Overloads Sub SetReplyTo( _ ByVal EmailAddress As String) Friend Overloads Sub SetReplyTo( _ ByVal EmailAddress As String, _ ByVal EmailName As String) C# internal void SetFrom( string EmailAddress) internal void SetFrom( string EmailAddress, string EmailName) internal void SetSender( string EmailAddress) internal void SetSender( string EmailAddress, string EmailName) internal void SetReplyTo( string EmailAddress) internal void SetReplyTo( string EmailAddress, string EmailName) Parameters
AppendTo / AppendCarbonCopy / AppendBlindCarbonCopy methods Syntax Visual Basic Friend Overloads Sub AppendTo( _ ByVal EmailAddress As String) Friend Overloads Sub AppendTo( _ ByVal EmailAddress As String, _ ByVal EmailName As String) Friend Overloads Sub AppendCarbonCopy( _ ByVal EmailAddress As String) Friend Overloads Sub AppendCarbonCopy( _ ByVal EmailAddress As String, _ ByVal EmailName As String) Friend Overloads Sub AppendBlindCarbonCopy( _ ByVal EmailAddress As String) Friend Overloads Sub AppendBlindCarbonCopy( _ ByVal EmailAddress As String, _ ByVal EmailName As String) C# internal void AppendTo( string EmailAddress) internal void AppendTo( string EmailAddress, string EmailName) internal void AppendCarbonCopy( string EmailAddress) internal void AppendCarbonCopy( string EmailAddress, string EmailName) internal void AppendBlindCarbonCopy( string EmailAddress) internal void AppendBlindCarbonCopy( string EmailAddress, string EmailName) Parameters
AppendAlternateView method Syntax Visual Basic Friend Overloads Sub AppendAlternateView( _ ByVal AlternateView As System.Net.Mail.AlternateView) C# internal void AppendAlternateView( System.Net.Mail.AlternateView AlternateView) Parameters
AppendAttachment method Syntax Visual Basic Friend Overloads Sub AppendAttachment( _ ByVal Attachment As System.Net.Mail.Attachment) C# internal void AppendAttachment( System.Net.Mail.Attachment Attachment) Parameters
Send methods Syntax Visual Basic Friend Overloads Sub Send( _ ByVal SmtpServer As String) Friend Overloads Sub Send( _ ByVal SmtpServer As String, _ ByVal SmtpPort As Integer, _ ByVal SmtpEncrypted As Boolean, _ ByVal SmtpTimeout As Integer, _ ByVal SmtpAuthenticated As Boolean, _ ByVal SmtpUsername As String, _ ByVal SmtpPassword As String) C# internal void Send( string SmtpServer) internal void Send( string SmtpServer, int SmtpPort, bool SmtpEncrypted, int SmtpTimeout, bool SmtpAuthenticated, string SmtpUsername, string SmtpPassword) Parameters
Example Use The code below shows an example of how to use the SMTP client class. Visual Basic Dim SmtpClient As Ferrysoft.Smtp Dim Attachment As System.Net.Mail.Attachment Dim AlternateView As System.Net.Mail.AlternateView Dim ContentType As System.Net.Mime.ContentType ' ' Create the SMTP client. ' SmtpClient = New Ferrysoft.Smtp() ' ' This example sends a plain text message. ' SmtpClient.Compose("Example 1 message subject", _ "Example plain text message") SmtpClient.SetFrom("jane.doe@example.com") SmtpClient.AppendTo("john.doe@example.com") SmtpClient.Send("smtp.example.com") ' ' This example sends an HTML message with ' multiple addresses for To:, Cc: and Bcc:. ' It also sets the Sender: and Reply-To: ' fields and sends the message with high ' priority. ' SmtpClient.Compose("Example 2 message subject", _ "<html><body>Example <b>HTML</b> message</body></html>", _ System.Text.Encoding.UTF8, _ System.Text.Encoding.UTF8, _ True, _ System.Net.Mail.MailPriority.High, _ System.Net.Mail.DeliveryNotificationOptions.None) SmtpClient.SetFrom("jane.doe@example.com", "Jane Doe") SmtpClient.SetSender("gary.doe@example.com", "Gary Doe") SmtpClient.SetReplyTo("henrietta.doe@example.com", _ "Henrietta Doe") SmtpClient.AppendTo("john.doe@example.com", "John Doe") SmtpClient.AppendTo("andy.doe@example.com") SmtpClient.AppendTo("bill.doe@example.com", "Bill Doe") SmtpClient.AppendCarbonCopy("cloe.doe@example.com", _ "Cloe Doe") SmtpClient.AppendCarbonCopy("david.doe@example.com") SmtpClient.AppendBlindCarbonCopy("eileen.doe@example.com") SmtpClient.AppendBlindCarbonCopy("fred.doe@example.com", _ "Fred Doe") SmtpClient.Send("smtp.example.com", _ 25, _ False, _ 30, _ True, _ "myusername", _ "mypassword") ' ' This example sends a message with both ' plain text and HTML views. This allows the ' recipient to see either a plain text view or ' an HTML view depending on the capabilities of ' the recipient's email client. ' The plain text view is composed in the message ' body and the HTML view is attached as an ' alternate view. ' The message requests delivery notification on ' success. ' The message also has three attachments. ' SmtpClient.Compose("Example 3 message subject", _ "Example plain text message", _ System.Text.Encoding.UTF8, _ System.Text.Encoding.UTF8, _ False, _ System.Net.Mail.MailPriority.Normal, _ System.Net.Mail.DeliveryNotificationOptions.OnSuccess) SmtpClient.SetFrom("jane.doe@example.com", "Jane Doe") SmtpClient.AppendTo("john.doe@example.com", "John Doe") ' ' Append an alternate view in HTML format. ' AlternateView = System.Net.Mail.AlternateView. _ CreateAlternateViewFromString( _ "<html><body>Example <b>HTML</b> message</body></html>", _ System.Text.Encoding.UTF8, _ System.Net.Mime.MediaTypeNames.Text.Html) SmtpClient.AppendAlternateView(AlternateView) ' ' Attach a Microsoft Word document. ' Attachment = New System.Net.Mail.Attachment( _ "C:\Test\Test1.docx", "application/msword") Attachment.ContentDisposition.DispositionType = _ System.Net.Mime.DispositionTypeNames.Attachment SmtpClient.AppendAttachment(Attachment) ' ' Attach a text file. Note that a ContentType ' is used to prepare the attachment so that ' the MediaType and CharSet can be explicitly ' specified. ' ContentType = New System.Net.Mime.ContentType() ContentType.MediaType = _ System.Net.Mime.MediaTypeNames.Text.Plain ContentType.CharSet = System.Text.Encoding.UTF8.WebName Attachment = New System.Net.Mail.Attachment( _ "C:\Test\Test1.txt", ContentType) Attachment.ContentDisposition.DispositionType = _ System.Net.Mime.DispositionTypeNames.Attachment SmtpClient.AppendAttachment(Attachment) ' ' Attach a text file created from a string. ' Attachment = System.Net.Mail.Attachment. _ CreateAttachmentFromString( _ "This is a text attachment", _ "Test2.txt", _ System.Text.Encoding.UTF8, _ System.Net.Mime.MediaTypeNames.Text.Plain) Attachment.ContentDisposition.DispositionType = _ System.Net.Mime.DispositionTypeNames.Attachment SmtpClient.AppendAttachment(Attachment) SmtpClient.Send("smtp.example.com", _ 25, _ False, _ 30, _ False, _ "", _ "") C# Ferrysoft.Smtp SmtpClient; System.Net.Mail.Attachment Attachment; System.Net.Mail.AlternateView AlternateView; System.Net.Mime.ContentType ContentType; // // Create the SMTP client. // SmtpClient = new Ferrysoft.Smtp(); // // This example sends a plain text message. // SmtpClient.Compose("Example 1 message subject", "Example plain text message"); SmtpClient.SetFrom("jane.doe@example.com"); SmtpClient.AppendTo("john.doe@example.com"); SmtpClient.Send("smtp.example.com"); // // This example sends an HTML message with // multiple addresses for To:, Cc: and Bcc:. // It also sets the Sender: and Reply-To: // fields and sends the message with high // priority. // SmtpClient.Compose("Example 2 message subject", "<html><body>Example <b>HTML</b> message</body></html>", System.Text.Encoding.UTF8, System.Text.Encoding.UTF8, true, System.Net.Mail.MailPriority.High, System.Net.Mail.DeliveryNotificationOptions.None); SmtpClient.SetFrom("jane.doe@example.com", "Jane Doe"); SmtpClient.SetSender("gary.doe@example.com", "Gary Doe"); SmtpClient.SetReplyTo("henrietta.doe@example.com", "Henrietta Doe"); SmtpClient.AppendTo("john.doe@example.com", "John Doe"); SmtpClient.AppendTo("andy.doe@example.com"); SmtpClient.AppendTo("bill.doe@example.com", "Bill Doe"); SmtpClient.AppendCarbonCopy("cloe.doe@example.com", "Cloe Doe"); SmtpClient.AppendCarbonCopy("david.doe@example.com"); SmtpClient.AppendBlindCarbonCopy("eileen.doe@example.com"); SmtpClient.AppendBlindCarbonCopy("fred.doe@example.com", "Fred Doe"); SmtpClient.Send("smtp.example.com", 25, false, 30, true, "myusername", "mypassword"); // // This example sends a message with both // plain text and HTML views. This allows the // recipient to see either a plain text view or // an HTML view depending on the capabilities of // the recipient's email client. // The plain text view is composed in the message // body and the HTML view is attached as an // alternate view. // The message requests delivery notification on // success. // The message also has three attachments. // SmtpClient.Compose("Example 3 message subject", "Example plain text message", System.Text.Encoding.UTF8, System.Text.Encoding.UTF8, false, System.Net.Mail.MailPriority.Normal, System.Net.Mail.DeliveryNotificationOptions.OnSuccess); SmtpClient.SetFrom("jane.doe@example.com", "Jane Doe"); SmtpClient.AppendTo("john.doe@example.com", "John Doe"); // // Append an alternate view in HTML format. // AlternateView = System.Net.Mail.AlternateView. CreateAlternateViewFromString( "<html><body>Example <b>HTML</b> message</body></html>", System.Text.Encoding.UTF8, System.Net.Mime.MediaTypeNames.Text.Html); SmtpClient.AppendAlternateView(AlternateView); // // Attach a Microsoft Word document. // Attachment = new System.Net.Mail.Attachment( "C:\\Test\\Test1.docx", "application/msword"); Attachment.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment; SmtpClient.AppendAttachment(Attachment); // // Attach a text file. Note that a ContentType // is used to prepare the attachment so that // the MediaType and CharSet can be explicitly // specified. // ContentType = new System.Net.Mime.ContentType(); ContentType.MediaType = System.Net.Mime.MediaTypeNames.Text.Plain; ContentType.CharSet = System.Text.Encoding.UTF8.WebName; Attachment = new System.Net.Mail.Attachment( "C:\\Test\\Test1.txt", ContentType); Attachment.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment; SmtpClient.AppendAttachment(Attachment); // // Attach a text file created from a string. // Attachment = System.Net.Mail.Attachment. CreateAttachmentFromString( "This is a text attachment", "Test2.txt", System.Text.Encoding.UTF8, System.Net.Mime.MediaTypeNames.Text.Plain); Attachment.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment; SmtpClient.AppendAttachment(Attachment); SmtpClient.Send("smtp.example.com", 25, false, 30, false, "", ""); |
|||||||||||||||||||||||||||||||||||||||||
| Copyright © 2004-2008 Ferrysoft Limited. All rights reserved. | |||||||||||||||||||||||||||||||||||||||||