1: using System;
2:
3: namespace Ia.Ngn.Cl.Model.Ui
4: {
5: ////////////////////////////////////////////////////////////////////////////
6:
7: /// <summary publish="true">
8: /// Mail process support class of Optical Fiber Network (OFN) UI model.
9: /// </summary>
10: ///
11: /// <remarks>
12: /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
13: ///
14: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
15: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
16: ///
17: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
18: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19: ///
20: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
21: ///
22: /// Copyright notice: This notice may not be removed or altered from any source distribution.
23: /// </remarks>
24: public class Mail
25: {
26: ////////////////////////////////////////////////////////////////////////////
27:
28: /// <summary>
29: ///
30: /// </summary>
31: public Mail()
32: {
33: }
34:
35: /////////////////////////////////////////////////////////////////////////////////
36:
37: /// <summary>
38: ///
39: /// </summary>
40: public static void Test(Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact, string subject, string bodyText, out string responseSubject, out string responseContent)
41: {
42: DateTime now;
43:
44: now = DateTime.UtcNow.AddHours(3);
45:
46: responseSubject = "Test (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
47:
48: responseContent = "Test: Daily Optical Fiber Network OFN Status Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
49: + "Status: undefined.\r\n"
50: + @"For help send ""help"" in a direct message." + "\r\n";
51: }
52:
53: /////////////////////////////////////////////////////////////////////////////////
54:
55: /// <summary>
56: ///
57: /// </summary>
58: public static void SendPlainMail(string name, string email, string subject, string content, out Ia.Cl.Model.Result result)
59: {
60: bool b;
61: string message;
62:
63: result = new Ia.Cl.Model.Result();
64:
65: message = Ia.Ngn.Cl.Model.Ui.Default.PlainMailTop();
66:
67: message += content;
68:
69: message += Ia.Ngn.Cl.Model.Ui.Default.PlainMailBottom();
70:
71:
72: b = global::Ia.Cl.Model.Smtp.SendPlain(name, email, subject, message); //, out result2);
73:
74: if (b) result.AddSuccess("Email sent. ");
75: else result.AddError("Email was not send:"); // + result2);
76: }
77:
78: /////////////////////////////////////////////////////////////////////////////////
79:
80: /// <summary>
81: ///
82: /// </summary>
83: public static bool SendMail(string name, string email, string subject, string content, out string result)
84: {
85: bool b;
86: string message;
87:
88: message = Ia.Ngn.Cl.Model.Ui.Default.MailTop();
89:
90: message += content;
91:
92: message += Ia.Ngn.Cl.Model.Ui.Default.MailBottom();
93:
94: result = string.Empty;
95:
96: b = global::Ia.Cl.Model.Smtp.SendHtml(name, email, subject, message); //, out result);
97:
98: if (b) result = "Email sent. ";
99: else result = "Email was not send: " + result;
100:
101: return b;
102: }
103:
104: ////////////////////////////////////////////////////////////////////////////
105: ////////////////////////////////////////////////////////////////////////////
106: }
107:
108: ////////////////////////////////////////////////////////////////////////////
109: ////////////////////////////////////////////////////////////////////////////
110: }