Smtp.NET 3 Documentation

SmtpServer.LogFileToString Method 

Returns the current log file as a string.

[Visual Basic]
Public Function LogFileToString( _
   ByVal htmlEncode As Boolean _
) As String
public string LogFileToString(
   bool htmlEncode


Encode for displaying in HTML context

Return Value

A string containing the log file.


Requires InMemoryLog to be set to True. This is useful for displaying in your application for debugging purposes.


            public void Send()
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");
                 oSmtpDotNet.InMemoryLog = true;
                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = ""
                 // Message Addressing
                 oSmtpDotNet.ToAddress = "";
                 oSmtpDotNet.FromAddress = "";
                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";
                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                      Console.WriteLine("Error #"+nRC+" occurred.");
                 // Success!
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes
                 oSmtpDotNet.InMemoryLog = true
                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = ""
                 ' Message Addressing
                 oSmtpDotNet.FromAddress = ""
                 oSmtpDotNet.ToAddress = ""
                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"
                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     ' Write out the log file contents
                     Exit Function
                 End If
                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace