[chronojump] New class NetworksSendMail to allow compujumps to send emails



commit eba88b1f0587c44cf307fc296ba14d17591e7934
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 19 11:45:09 2019 +0200

    New class NetworksSendMail to allow compujumps to send emails

 src/networks.cs | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/src/networks.cs b/src/networks.cs
index a490e783..c357dd97 100644
--- a/src/networks.cs
+++ b/src/networks.cs
@@ -100,3 +100,38 @@ public class Networks
                return true; //by default screen is on. If detection is wrong user can touch screen
        }
 }
+
+public class NetworksSendMail
+{
+       //filename is the image
+       //public ExecuteProcess.Result execute_result;
+       public string ErrorStr = "";
+
+       public NetworksSendMail ()
+       {
+               ErrorStr = "";
+       }
+
+       public bool Send (string filename, string email)
+       {
+               //echo "See attached file" |mailx -s "$HOSTNAME Testing attachment" -A 
/home/chronojump/chronojump/images/calendar.png testing chronojump org
+
+               List<string> parameters = new List<string>();
+               parameters.Add("-s");
+               parameters.Add("\"myHostName: myTitle\"");
+               parameters.Add("-A");
+               parameters.Add(filename);
+               parameters.Add(email);
+
+               //note redirect output and error is false because if redirect input there are problems 
redirecting the others
+               ExecuteProcess.Result execute_result = ExecuteProcess.run ("mail.mailutils", parameters, 
"myBody", false, false);
+               if(! execute_result.success) {
+                       ErrorStr = "Need to install mail.mailutils";
+               }
+
+               return execute_result.success;
+       }
+
+       // another option will be use C-sharp methods, see:
+       // 
https://stackoverflow.com/questions/2825950/sending-email-with-attachments-from-c-attachments-arrive-as-part-1-2-in-thunde
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]