NET Logging Library
EmailLogFile(EmailParameters,BaseFileTarget) Method
Example 



KellermanSoftware.NetLoggingLibrary Namespace > Log Class > EmailLogFile Method : EmailLogFile(EmailParameters,BaseFileTarget) Method
Email a log file for the specified file target
Syntax
Public Overloads Shared Sub EmailLogFile( _
   ByVal parameters As EmailParameters, _
   ByVal fileTarget As BaseFileTarget _
) 
Dim parameters As EmailParameters
Dim fileTarget As BaseFileTarget
 
Log.EmailLogFile(parameters, fileTarget)
public static void EmailLogFile( 
   EmailParameters parameters,
   BaseFileTarget fileTarget
)
public:
static void EmailLogFile( 
   EmailParameters^ parameters,
   BaseFileTarget^ fileTarget
) 

Parameters

parameters
fileTarget
Example
//Licensed Mode
//Log.UserName = "User Name From Receipt";
//Log.LicenseKey = "LicenseKey From Receipt";            
 
//Clear all configuration
Log.ResetConfiguration();
 
//Add a new target, you can also define targets in an xml file, app.config, or web.config
FileTarget fileTarget = new FileTarget(Environment.CurrentDirectory + "\\fileLogger.txt");
Log.Config.Targets.Add(fileTarget);
 
//Parameters
EmailParameters parameters = new EmailParameters();
parameters.SmtpServer = "mail.example.com";
parameters.SmtpPort = 25;
parameters.FromEmail = "testemail@example.com";
parameters.ToEmail = "testemail2@example.com";
parameters.Bcc = "";
parameters.Subject = "Logging message";
parameters.IsBodyHtml = true;
parameters.UserName = "testemail@example.com";
parameters.Password = "secret";
 
Log.Debug("Test Message");
 
//Close the connection so we can email it as an attachment
fileTarget.CloseConnection();
 
//Email the log file as an attachment
Log.EmailLogFile(parameters, fileTarget);
'Licensed Mode
'Log.UserName = "User Name From Receipt";
'Log.LicenseKey = "LicenseKey From Receipt";            
 
'Clear all configuration
Log.ResetConfiguration()
 
'Add a new target, you can also define targets in an xml file, app.config, or web.config
Dim fileTarget As New FileTarget(Environment.CurrentDirectory & "\fileLogger.txt")
Log.Config.Targets.Add(fileTarget)
 
'Parameters
Dim parameters As New EmailParameters()
parameters.SmtpServer = "mail.example.com"
parameters.SmtpPort = 25
parameters.FromEmail = "testemail@example.com"
parameters.ToEmail = "testemail2@example.com"
parameters.Bcc = ""
parameters.Subject = "Logging message"
parameters.IsBodyHtml = True
parameters.UserName = "testemail@example.com"
parameters.Password = "secret"
 
Log.Debug("Test Message")
 
'Close the connection so we can email it as an attachment
fileTarget.CloseConnection()
 
'Email the log file as an attachment
Log.EmailLogFile(parameters, fileTarget)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Log Class
Log Members
Overload List