Browse Source

Added e-mail debug

Stuart Johnson 1 year ago
parent
commit
9d490c8c78
4 changed files with 48 additions and 30 deletions
  1. 10 8
      .vs/TFA-Bot/xs/UserPrefs.xml
  2. 5 5
      TFA-Bot/TFA-Bot.csproj
  3. 28 12
      TFA-Bot/clsEmail.cs
  4. 5 5
      TFA-Bot/packages.config

+ 10 - 8
.vs/TFA-Bot/xs/UserPrefs.xml

@@ -1,6 +1,6 @@
 <Properties StartupConfiguration="{25609AB4-A77A-4B47-AAB8-B2DB39464A3F}|Default">
   <MonoDevelop.Ide.ItemProperties.TFA-Bot PreferredExecutionTarget="MonoDevelop.Default" />
-  <MonoDevelop.Ide.Workbench ActiveDocument="TFA-Bot/DiscordBot/Commands/clsHelp.cs">
+  <MonoDevelop.Ide.Workbench ActiveDocument="TFA-Bot Status">
     <Files>
       <File FileName="TFA-Bot/DiscordBot/Commands/clsHelp.cs" Line="44" Column="1" />
       <File FileName="TFA-Bot/DiscordBot/Commands/clsNetworks.cs" Line="32" Column="45" />
@@ -11,26 +11,28 @@
       <File FileName="TFA-Bot/DataClasses/clsNodeGroup.cs" Line="57" Column="44" />
       <File FileName="TFA-Bot/DataClasses/clsNode.cs" Line="424" Column="17" />
       <File FileName="TFA-Bot/DiscordBot/clsBotClient.cs" Line="169" Column="84" />
-      <File FileName="TFA-Bot/clsEmail.cs" Line="96" Column="14" />
+      <File FileName="TFA-Bot/clsEmail.cs" Line="92" Column="59" />
       <File FileName="TFA-Bot/clsAlarm.cs" Line="82" Column="55" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsDiscord.cs" Line="32" Column="13" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsDiscord.cs" Line="31" Column="13" />
       <File FileName="TFA-Bot/DiscordBot/Commands/clsGoodnight.cs" Line="31" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsEmail.cs" Line="30" Column="1" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsEmail.cs" Line="21" Column="25" />
       <File FileName="TFA-Bot/DiscordBot/Commands/clsAlarm.cs" Line="1" Column="1" />
       <File FileName="TFA-Bot/DiscordBot/Commands/IBotCommand.cs" Line="21" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/clsCommands.cs" Line="40" Column="60" />
+      <File FileName="TFA-Bot/DiscordBot/clsCommands.cs" Line="73" Column="31" />
       <File FileName="TFA-Bot/clsColumnDisplay.cs" Line="20" Column="50" />
-      <File FileName="TFA-Bot/Spreadsheet/clsSpreadsheet.cs" Line="26" Column="58" />
+      <File FileName="TFA-Bot/Spreadsheet/clsSpreadsheet.cs" Line="15" Column="38" />
       <File FileName="TFA-Bot/Spreadsheet/ASheetColumnHeader.cs" Line="1" Column="1" />
       <File FileName="TFA-Bot/Spreadsheet/ISpreadsheet.cs" Line="1" Column="1" />
       <File FileName="TFA-Bot/Utils/clsRollingAverage.cs" Line="48" Column="1" />
+      <File FileName="TFA-Bot/Spreadsheet/clsSpreadsheetReader.cs" Line="15" Column="16" />
+      <File FileName="TFA-Bot Status" />
     </Files>
     <Pads>
       <Pad Id="ProjectPad">
         <State name="__root__">
           <Node name="TFA-Bot" expanded="True">
-            <Node name="TFA-Bot" expanded="True">
-              <Node name="Packages" selected="True" />
+            <Node name="TFA-Bot" expanded="True" selected="True">
+              <Node name="Packages" expanded="True" />
               <Node name="DataClasses" expanded="True" />
               <Node name="DiscordBot" expanded="True">
                 <Node name="Commands" expanded="True" />

+ 5 - 5
TFA-Bot/TFA-Bot.csproj

@@ -1,5 +1,5 @@
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\packages\LibGit2Sharp.NativeBinaries.2.0.267\build\net46\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.2.0.267\build\net46\LibGit2Sharp.NativeBinaries.props')" />
+  <Import Project="..\packages\LibGit2Sharp.NativeBinaries.2.0.289\build\net46\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.2.0.289\build\net46\LibGit2Sharp.NativeBinaries.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -79,19 +79,19 @@
       <HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath>
     </Reference>
     <Reference Include="LibGit2Sharp">
-      <HintPath>..\packages\LibGit2Sharp.0.26.0\lib\net46\LibGit2Sharp.dll</HintPath>
+      <HintPath>..\packages\LibGit2Sharp.0.26.1\lib\net46\LibGit2Sharp.dll</HintPath>
     </Reference>
     <Reference Include="Newtonsoft.Json">
       <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="MimeKit">
-      <HintPath>..\packages\MimeKit.2.1.5.1\lib\net45\MimeKit.dll</HintPath>
+      <HintPath>..\packages\MimeKit.2.3.2\lib\net46\MimeKit.dll</HintPath>
     </Reference>
     <Reference Include="MailKit">
-      <HintPath>..\packages\MailKit.2.1.5.1\lib\net45\MailKit.dll</HintPath>
+      <HintPath>..\packages\MailKit.2.3.2\lib\net46\MailKit.dll</HintPath>
     </Reference>
     <Reference Include="RestSharp">
-      <HintPath>..\packages\RestSharp.106.6.9\lib\net452\RestSharp.dll</HintPath>
+      <HintPath>..\packages\RestSharp.106.6.10\lib\net452\RestSharp.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>

+ 28 - 12
TFA-Bot/clsEmail.cs

@@ -61,20 +61,36 @@ namespace TFABot
         
                     message.Body = new TextPart ("plain") { Text = Message  };
         
-                    using (var client = new SmtpClient ()) {
-                        // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
-                        client.ServerCertificateValidationCallback = (s,c,h,e) => true;
-        
-                        client.Connect (SMTPHost, SMTPPort, SecureSocketOptions.Auto );
         
-                        // Note: only needed if the SMTP server requires authentication
-                        client.Authenticate (SMTPUsername, SMTPPassword);
-                        client.Timeout = 10000;
-                        client.Send (message);
-                        client.Disconnect (true);
+                    using (var client = new SmtpClient ()) {
+
+                        try
+                        {
+                            // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
+                            client.ServerCertificateValidationCallback = (s, c, h, e) => true;
+
+                            client.Connect(SMTPHost, SMTPPort, SecureSocketOptions.Auto);
+
+                            // Note: only needed if the SMTP server requires authentication
+                            client.Authenticate(SMTPUsername, SMTPPassword);
+                            client.Timeout = 10000;
+                            client.Send(message);
+                            client.Disconnect(true);
+
+                            if (ChBotAlert != null)
+                                ChBotAlert.SendMessageAsync($"Sent e-mail {To}");
+
+                        }
+                        catch (Exception ex)
+                        {
 
-                        if (ChBotAlert!=null)
-                               ChBotAlert.SendMessageAsync($"Sent e-mail {To}");
+                            if (ChBotAlert != null)
+                            {
+                                ChBotAlert.SendMessageAsync($"FAILED: e-mail {To}");
+                                ChBotAlert.SendMessageAsync($"```{ex.Message}```");
+                            }
+                            Console.WriteLine(ex.Message);
+                        }
                         
                     }
                 });

+ 5 - 5
TFA-Bot/packages.config

@@ -5,12 +5,12 @@
   <package id="DSharpPlus.CommandsNext" version="3.2.3" targetFramework="net462" />
   <package id="DSharpPlus.Interactivity" version="3.2.3" targetFramework="net462" />
   <package id="DSharpPlus.WebSocket.WebSocketSharp" version="3.2.3" targetFramework="net462" />
-  <package id="LibGit2Sharp" version="0.26.0" targetFramework="net462" />
-  <package id="LibGit2Sharp.NativeBinaries" version="2.0.267" targetFramework="net462" />
-  <package id="MailKit" version="2.1.5.1" targetFramework="net462" />
-  <package id="MimeKit" version="2.1.5.1" targetFramework="net462" />
+  <package id="LibGit2Sharp" version="0.26.1" targetFramework="net462" />
+  <package id="LibGit2Sharp.NativeBinaries" version="2.0.289" targetFramework="net462" />
+  <package id="MailKit" version="2.3.2" targetFramework="net462" />
+  <package id="MimeKit" version="2.3.2" targetFramework="net462" />
   <package id="Newtonsoft.Json" version="12.0.2" targetFramework="net462" />
-  <package id="RestSharp" version="106.6.9" targetFramework="net462" />
+  <package id="RestSharp" version="106.6.10" targetFramework="net462" />
   <package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
   <package id="WebSocketSharp-NonPreRelease" version="1.0.0" targetFramework="net462" />
 </packages>