Pop3Client Activity Logging

Contents
[ ]

Pop3Client activity can be logged by modifying the configSections in the config file. Following are the steps to perform diagnostics logging:

  1. Add a sectionGroup called “applicationSettings”.
  2. Add a section called “Aspose.Email.Properties.Settings”.
  3. Include the setting ImapDiagonosticLog where the file name is defined in the applicationSettings/Aspose.Email.Properties.Settings.

Here is a sample form application which uses Pop3Client to process mail. This whole activity is logged by modifying the App.config file.

  • Create a form based application with a single button on it. Add the following sample code for button’s click:
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
Pop3Client client = new Pop3Client("pop.gmail.com", 995, "user@gmail.com", "password");
// Set security mode
client.SecurityOptions = SecurityOptions.Auto;
try
{
// Get the message info collection
Pop3MessageInfoCollection list = client.ListMessages();
// Download each message
for (int i = 0; i < list.Count; i++)
{
// Save the EML file locally
client.SaveMessage(list[i].UniqueId, dataDir + list[i].UniqueId + ".eml");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
  • Add a reference to Aspose.Email.
  • Now add the App.Config file and modify it in so that the file contents are as follows:
For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Aspose.Email.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<Aspose.Email.Properties.Settings>
<setting name="Pop3DiagnosticLog" serializeAs="String">
<value>Aspose.Email.Pop3.log</value>
</setting>
<setting name="Pop3DiagnosticLog_UseDate" serializeAs="String">
<value>True</value>
</setting>
</Aspose.Email.Properties.Settings>
</applicationSettings>
</configuration>

For C# .NET use the following option

todo:image_alt_text
For VB .NET use the following option
todo:image_alt_text   todo:image_alt_text  
todo:image_alt_text  
  • Run the code and then observe the Log folder. The following file will be generated.
todo:image_alt_text