Anda di halaman 1dari 6

J:\Source Code\eSMS\eSMS\frmMain.

cs 1
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Net.Mime;
8 using System.Net.Mail;
9 using System.Windows.Forms;
10 using System.Xml;
11 using System.IO;
12
13 namespace eSMS
14 {
15 public partial class frmMain : Form
16 {
17 public string AppTitle = "eSMS";
18 internal string BCCEmail;
19 internal string EmailAddRecipient;
20 internal string FromEmail;
21 internal string eMailMess;
22 internal string serverNameorIP;
23 public bool sentToday;
24
25 public frmMain()
26 {
27 InitializeComponent();
28 }
29
30 private void setServerSettings()
31 {
32 BCCEmail = txtBCC.Text;
33 this.loadRec();
34 FromEmail = txtAddress.Text;
35 eMailMess = txtMessage.Text;
36 serverNameorIP = txtServer.Text;
37 // MessageBox.Show(EmailAddRecipient);
38 }
39 private void loadRec()
40 {
41 EmailAddRecipient = "";
42
43 foreach (string Item in listNumbers.Items)
44 {
45 EmailAddRecipient = EmailAddRecipient + Item + "; ";
46 }
47 }
48
49 private void EmailSMS(string Message, string EmailAddRec, string passName,
bool SkipMsgBox)
50 {
51
52 String message1 = Message;
53 DateTime now = DateTime.Now.Date;
54
55
56 MailMessage message = new MailMessage(
57 FromEmail,
58 listNumbers.Items[0].ToString(),
59 "",
60 message1);
61
62 foreach (string strAddress in listNumbers.Items)
63 {
64 message.To.Add(strAddress);
65 }
66
J:\Source Code\eSMS\eSMS\frmMain.cs 2
67 message.Bcc.Add(new MailAddress(BCCEmail));
68 message.IsBodyHtml = false;
69
70 SmtpClient client = new SmtpClient(serverNameorIP);
71
72 client.UseDefaultCredentials = true;
73
74 try
75 {
76 client.Send(message);
77 if (!SkipMsgBox)
78 {
79 MessageBox.Show(passName + " SMS has been sent",
80 "SMS: " + this.AppTitle,
81 MessageBoxButtons.OK,
82 MessageBoxIcon.Information);
83 }
84 else
85 {
86 this.ntyeSMS.BalloonTipText = passName +
87 " SMS has been sent!";
88 this.ntyeSMS.Text = this.AppTitle + ": SMS";
89 this.ntyeSMS.ShowBalloonTip(0x1388);
90 }
91 }
92 catch (Exception exception1)
93 {
94 Exception exception = exception1;
95 if (!SkipMsgBox)
96 {
97 MessageBox.Show("There was some exception: " +
98 exception.Message,
99 "Exception: " + this.AppTitle,
100 MessageBoxButtons.OK,
101 MessageBoxIcon.Exclamation);
102 }
103 else
104 {
105 this.ntyeSMS.BalloonTipText = "There was some exception: " +
exception.Message;
106 this.ntyeSMS.Text = this.AppTitle +
107 ": Error Sending";
108 this.ntyeSMS.ShowBalloonTip(0x1388);
109 }
110 }
111
112
113 try{
114 }
115 catch
116 {
117 ntyeSMS.ShowBalloonTip
118 (5000,
119 AppTitle,
120 "Something went wrong!",
121 ToolTipIcon.Error);
122
123 }
124 }
125
126 private void frmMain_Load(object sender, EventArgs e)
127 {
128 this.loadConfig();
129 this.loadProviders();
130 ntyeSMS.ShowBalloonTip
131 (5000,
132 AppTitle,
J:\Source Code\eSMS\eSMS\frmMain.cs 3
133 "Welcome to eSMS!",
134 ToolTipIcon.Info);
135
136 }
137 private void loadConfig()
138 {
139
140 }
141 private void loadProviders()
142 {
143 XmlDocument doc = new XmlDocument();
144
145 doc.Load(Directory.GetCurrentDirectory().
146 ToString() +
147 @"\US-Providers.xml");
148 XmlNodeList nodes = doc.SelectNodes(
149 "/xml/name/@* | /xml/name/text()");
150 foreach (XmlNode node in nodes)
151 {
152 cmbCarrier.Items.Add(node.Value);
153 }
154
155 nodes = doc.SelectNodes(
156 "/xml/number/@* | /xml/number/text()");
157 foreach (XmlNode node in nodes)
158 {
159 cmbNumb.Items.Add(node.Value);
160 }
161
162
163
164 }
165
166 private void cmbCarrier_SelectedIndexChanged(object sender, EventArgs e)
167 {
168
169 cmbNumb.SelectedIndex = cmbCarrier.SelectedIndex;
170
171 lblAddy.Text = cmbNumb.Text;
172 lblAddy.Text =
173
174
175 txtNum1.Text + txtNum2.Text + txtNum3.Text + cmbNumb.Text;
176 tsStatuseSMS.Text = cmbCarrier.Text + " selected";
177
178 }
179
180 private void tabSMS_Click(object sender, EventArgs e)
181 {
182
183 }
184
185 private void txtNum1_TextChanged(object sender, EventArgs e)
186 {
187 lblAddy.Text = txtNum1.Text +
188 txtNum2.Text + txtNum3.Text + cmbNumb.Text;
189 }
190
191 private void txtNum2_TextChanged(object sender, EventArgs e)
192 {
193 lblAddy.Text = txtNum1.Text +
194 txtNum2.Text + txtNum3.Text + cmbNumb.Text;
195
196 }
197
198 private void txtNum3_TextChanged(object sender, EventArgs e)
199 {
J:\Source Code\eSMS\eSMS\frmMain.cs 4
200 lblAddy.Text = txtNum1.Text +
201 txtNum2.Text + txtNum3.Text + cmbNumb.Text;
202 }
203
204 private void btnAdd_Click(object sender, EventArgs e)
205 {
206 listNumbers.Items.Add(lblAddy.Text);
207 }
208
209 private void tsDeleteMenu_Click(object sender, EventArgs e)
210 {
211 listNumbers.Items.Remove(listNumbers.SelectedItem);
212 }
213
214 private void chkReoccur_CheckedChanged(object sender, EventArgs e)
215 {
216 if (chkReoccur.Checked == true)
217 {
218 datePicker.Enabled = true;
219 timePicker.Enabled = true;
220 tsStatuseSMS.Text = "Reoccurrence Selected";
221 }
222 else
223 {
224 datePicker.Enabled = false;
225 timePicker.Enabled = false;
226 tsStatuseSMS.Text = "Reoccurrence Deselected";
227 }
228 }
229
230 private void chkReoccur_Click(object sender, EventArgs e)
231 {
232 if (chkReoccur.Checked == true)
233 {
234 datePicker.Enabled = true;
235 timePicker.Enabled = true;
236
237 }
238 else
239 {
240 datePicker.Enabled = false;
241 timePicker.Enabled = false;
242 }
243 }
244 private void ExitMe()
245 {
246 if (MessageBox.Show(
247 "Are you sure you want to exit? Click yes to confirm and no to
continue",
248 AppTitle + ": Exit",
249 MessageBoxButtons.YesNo,
250 MessageBoxIcon.Question) ==
251 DialogResult.Yes)
252 {
253 Application.Exit();
254 }
255 else
256 {
257
258 }
259 }
260
261 private void btnExit_Click(object sender, EventArgs e)
262 {
263 this.ExitMe();
264 }
265
J:\Source Code\eSMS\eSMS\frmMain.cs 5
266 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
267 {
268 this.ExitMe();
269 }
270
271 private void btnMailConfig_Click(object sender, EventArgs e)
272 {
273 tabControl1.SelectedIndex = 1;
274 }
275
276 private void btnLogs_Click(object sender, EventArgs e)
277 {
278 tabControl1.SelectedIndex = 2;
279 }
280
281 private void toolStripMenuItem3_Click(object sender, EventArgs e)
282 {
283 tabControl1.SelectedIndex = 1;
284
285 }
286
287 private void toolStripMenuItem1_Click(object sender, EventArgs e)
288 {
289 tabControl1.SelectedIndex = 2;
290
291 }
292
293 private void tsStatuseSMS_Click(object sender, EventArgs e)
294 {
295
296 }
297
298 private void tsStatuseSMS_TextChanged(object sender, EventArgs e)
299 {
300 txtLog.Text = txtLog.Text + tsStatuseSMS.Text + "\r\n";
301 }
302
303 private void btnHideShow_Click(object sender, EventArgs e)
304 {
305 this.ShowHide();
306 }
307 private void ShowHide()
308 {
309 if (this.Visible == true)
310 {
311 this.Visible = false;
312 }
313 else
314 {
315 this.Visible = true;
316 }
317 }
318
319 private void hideShowToolStripMenuItem_Click(object sender, EventArgs e)
320 {
321 this.ShowHide();
322 }
323
324 private void ntyeSMS_MouseDoubleClick(object sender, MouseEventArgs e)
325 {
326 this.ShowHide();
327 }
328
329 private void label2_Click(object sender, EventArgs e)
330 {
331
332 }
J:\Source Code\eSMS\eSMS\frmMain.cs 6
333
334 private void statusStrip1_ItemClicked(object sender,
ToolStripItemClickedEventArgs e)
335 {
336
337 }
338
339 private void btnSendeSMS_Click(object sender, EventArgs e)
340 {
341 this.setServerSettings();
342
343 tsStatuseSMS.Text = "Sending SMS to: " + EmailAddRecipient;
344 ntyeSMS.ShowBalloonTip
345 (5000,
346 AppTitle,
347 "Sending SMS to: " + EmailAddRecipient,
348 ToolTipIcon.Warning);
349
350 this.EmailSMS(eMailMess,
351 EmailAddRecipient,
352 AppTitle + ": ",
353 true);
354
355 }
356
357
358 }
359 }
360
361

Anda mungkin juga menyukai