PowerTCP Mail for .NET
SentLength Property
See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace > SmtpResult Class : SentLength Property




After any method that is used to send an email message (such as Smtp.Send or Smtp.BeginSend) has completed, this property gets the total length of all data sent.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property SentLength As Long
Visual Basic (Usage)Copy Code
Dim instance As SmtpResult
Dim value As Long
 
value = instance.SentLength
C# 
public long SentLength {get;}
Managed Extensions for C++ 
public: __property long get_SentLength();
C++/CLI 
public:
property int64 SentLength {
   int64 get();
}

Property Value

A long representing the length of all data sent.

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

After the message is sent, check this property to see the number of bytes of data sent.

This data is also accessible via the Smtp.Progress event, when the send is completed.

The Smtp.Length property is useful for displaying data to the user, or if you need to know the length of data sent for any other reason (such as buffer initialization).

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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