Specifies whether Smtp.NET should automatically choose a random name for the log file.
If true, the log file is created using a unique name in the path specified with the TempDirectory property. If false, the log file is not automatically generated.
The automatically named log file is placed in the temporary directory set with the TempDirectory property. The name of the log file can be retrieved, after the Send or MailMerge method is called, with the LogFilename property. Setting this property overrides value specified with LogFilename property or the log filename specified in the constructor of the SmtpServer class.
[C#]
public void Send()
{
SmtpServer oSmtpDotNet = new SmtpServer();
// Make the object create a unique log file name
oSmtpDotNet.AutoNameLogFile = true;
// Set the remote server name. If left blank, "localhost" is used.
oSmtpDotNet.ServerAddress = "mail.domain.com";
// Message Addressing
oSmtpDotNet.ToAddress = "to@domain.com";
oSmtpDotNet.FromAddress = "from@domain.com";
// 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.");
Console.WriteLine(oSmtpDotNet.LastError);
Console.Write(oSmtpDotNet.LogFileToString(false));
return;
}
// Success!
Console.WriteLine("Success!");
// Display the log filename
Console.WriteLine(oSmtpDotNet.Logfilename);
}
[VB]
Public Function Send() As Integer
Dim oSmtpDotNet As New SmtpServer()
Dim nRC As ReturnCodes
' Make the object create a unique log file name
oSmtpDotNet.AutoNameLogFile = true
' Set the remote server name. If left blank, "localhost" is used.
oSmtpDotNet.ServerAddress = "mail.domain.com"
' Message Addressing
oSmtpDotNet.FromAddress = "from@domain.com"
oSmtpDotNet.ToAddress = "to@domain.com"
' 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
Console.WriteLine(oSmtpDotNet.LastError)
' Write out the log file contents
Console.WriteLine(oSmtpDotNet.LogFileToString(False))
Exit Function
End If
' Success!
Console.WriteLine("Message Sent!")
' Display the log filename
Console.WriteLine(oSmtpDotNet.Logfilename)
End Function
[C#]
bool bAutoNameLogFile = oSmtpDotNet.AutoNameLogFile;
oSmtpDotNet.AutoNameLogFile = true;SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace