NET Logging Library
EmailLogFile(EmailParameters,BaseFileTarget) Method
Example 



KellermanSoftware.NetLoggingLibrary Namespace > ConcreteLog Class > EmailLogFile Method : EmailLogFile(EmailParameters,BaseFileTarget) Method
Email the log file of a file target. Works with FileTarget, HtmlTarget, CsvTarget, and XmlTarget
Syntax
Public Overloads Sub EmailLogFile( _
   ByVal parameters As EmailParameters, _
   ByVal fileTarget As BaseFileTarget _
) 
Dim instance As ConcreteLog
Dim parameters As EmailParameters
Dim fileTarget As BaseFileTarget
 
instance.EmailLogFile(parameters, fileTarget)
public void EmailLogFile( 
   EmailParameters parameters,
   BaseFileTarget fileTarget
)
public:
void EmailLogFile( 
   EmailParameters^ parameters,
   BaseFileTarget^ fileTarget
) 

Parameters

parameters
fileTarget
Example
ConcreteLog logger = new ConcreteLog();
 
//Licensed Mode
//logger.UserName = "User Name From Receipt";
//logger.LicenseKey = "LicenseKey From Receipt";            
 
//Clear all configuration
logger.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");
logger.Config.Targets.Add(fileTarget);
 
//Parameters
EmailParameters parameters = new EmailParameters();
parameters.SmtpServer = "mail.example.com";
parameters.SmtpPort = 587;
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";
 
logger.Debug("Test Message");
 
//Close the connection so we can email it as an attachment
fileTarget.CloseConnection();
 
//Email the log file as an attachment
logger.EmailLogFile(parameters, fileTarget);
Dim logger As New ConcreteLog()
 
'Licensed Mode
'logger.UserName = "User Name From Receipt";
'logger.LicenseKey = "LicenseKey From Receipt";            
 
'Clear all configuration
logger.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")
logger.Config.Targets.Add(fileTarget)
 
'Parameters
Dim parameters As New EmailParameters()
parameters.SmtpServer = "mail.example.com"
parameters.SmtpPort = 587
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"
 
logger.Debug("Test Message")
 
'Close the connection so we can email it as an attachment
fileTarget.CloseConnection()
 
'Email the log file as an attachment
logger.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

ConcreteLog Class
ConcreteLog Members
Overload List