PowerTCP Mail for .NET
SmtpResult Class
Members  Example  See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace : SmtpResult Class




Represents the results from an SMTP send operation.

Object Model

SmtpResult ClassMailAddresses ClassMailAddress Class

Syntax

Visual Basic (Declaration) 
Public Class SmtpResult 
Visual Basic (Usage)Copy Code
Dim instance As SmtpResult
C# 
public class SmtpResult 
Managed Extensions for C++ 
public __gc class SmtpResult 
C++/CLI 
public ref class SmtpResult 

Example

The following example demonstrates using the Smtp component to override the addresses used for the SMTP envelope.
Visual BasicCopy Code
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.

' First create a message
Dim msg As New MessageStream()

' Add a "TO:" header line
msg.To.Add(New MailAddress("you@test.com"))

' Add a "FROM:" header line
msg.From = New MailAddress("me@test.com")

' Add a "SUBJECT:" header line
msg.Subject = "Test"

' Add some text
msg.Text = "test message"

' If the message is sent now, "me@test.com" would be sent after the SMTP
' "MAIL FROM" command and "you@test.com" would be sent after the SMTP "RCPT
' TO" command. You can override this, however, by explicitly setting the 
' addresses that will be used for the SMTP envelope as the following code demonstrates.

' Explicitly specify the email to use for "MAIL FROM" (This will NOT be included in the header)
Smtp1.MailFrom = New MailAddress("sender@test.com")

' Explicitly specify the email to use for "RCPT TO"; (This will NOT be included in the header)
Smtp1.Recipients.Add(New MailAddress("receiver@test.com"))

' Send the message, this will return an SmtpResult object
Smtp1.Server = "mail.test.com"
Dim result As SmtpResult = Smtp1.Send(msg)

' Check the information about the message sent
Debug.WriteLine("Bytes of data Sent: " + result.SentLength)
Dim ma As MailAddress
For Each ma In result.Recipients
   Debug.WriteLine("Mail sent to: " + ma.Address)
Next

' Output
' --------------------------------
' Bytes of data sent: 477
' Mail sent to: <receiver@test.com>
C#Copy Code
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.

// First create a message
MessageStream msg = new MessageStream();

// Add a "TO:" header line
msg.To.Add(new MailAddress("you@test.com"));

// Add a "FROM:" header line
msg.From = new MailAddress("me@test.com");

// Add a "SUBJECT:" header line
msg.Subject = "Test";

// Add some text
msg.Text = "test message";

// If the message is sent now, "me@test.com" would be sent after the SMTP
// "MAIL FROM" command and "you@test.com" would be sent after the SMTP "RCPT
// TO" command. You can override this, however, by explicitly setting the 
// addresses that will be used for the SMTP envelope as the following code demonstrates.

// Explicitly specify the email to use for "MAIL FROM" (This will NOT be included in the header)
smtp1.MailFrom = new MailAddress("sender@test.com");

// Explicitly specify the email to use for "RCPT TO"; (This will NOT be included in the header)
smtp1.Recipients.Add(new MailAddress("receiver@test.com"));

// Send the message, this will return an SmtpResult object
smtp1.Server = "mail.dart.com";
SmtpResult result = smtp1.Send(msg);

// Check the information about the message sent
Debug.WriteLine("Bytes of data Sent: " + result.SentLength);
foreach(MailAddress ma in result.Recipients)
   Debug.WriteLine("Mail sent to: " + ma.Address);

// Output
// --------------------------------
// Bytes of data sent: 477
// Mail sent to: <receiver@test.com>

Remarks

When any email message is sent using Smtp.Send an SmtpResult object is returned from the method. When using asynchronous methods such as Smtp.BeginSend this object is passed into the event handler as part of the SmtpEventArgs class.

The SmtpResult object encapsulates data about the sent email message. Data available in this object includes a collection of recipients to which the SMTP mail server replied successfully to, as well as the byte count of all data sent.

Inheritance Hierarchy

System.Object
   Dart.PowerTCP.Mail.SmtpResult

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.