SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | using System.Collections.Generic; | |
3 | using System.ComponentModel; | |
4 | using System.Data; | |
5 | using System.Drawing; | |
6 | using System.Linq; | |
7 | using System.Text; | |
8 | using System.Threading.Tasks; | |
9 | using System.Windows.Forms; | |
10 | using System.Net; | |
11 | using System.Net.Mail; | |
12 | ||
13 | namespace תוכנה_מצויינת_למיקמק_עובדת | |
14 | { | |
15 | public partial class Form1 : Form | |
16 | { | |
17 | public Form1() | |
18 | { | |
19 | InitializeComponent(); | |
20 | } | |
21 | ||
22 | private void button1_Click(object sender, EventArgs e) | |
23 | { | |
24 | string smtpAddress = "smtp.gmail.com"; | |
25 | int portNumber = 587; | |
26 | bool enableSSL = true; | |
27 | ||
28 | string emailFrom = "oded4664@gmail.com"; | |
29 | string password = "*******"; | |
30 | string emailTo = "oded4664@gmail.com"; | |
31 | string subject = "Hello"; | |
32 | string body = "Hello, I'm just writing this to say Hi!"; | |
33 | ||
34 | using (MailMessage mail = new MailMessage()) | |
35 | { | |
36 | mail.From = new MailAddress(emailFrom); | |
37 | mail.To.Add(emailTo); | |
38 | mail.Subject = subject; | |
39 | mail.Body = body; | |
40 | mail.IsBodyHtml = true; | |
41 | // Can set to false, if you are sending pure text. | |
42 | ||
43 | //mail.Attachments.Add(new Attachment("C:\\SomeFile.txt")); | |
44 | //mail.Attachments.Add(new Attachment("C:\\SomeZip.zip")); | |
45 | ||
46 | using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber)) | |
47 | { | |
48 | smtp.Credentials = new NetworkCredential(emailFrom, password); | |
49 | smtp.EnableSsl = enableSSL; | |
50 | smtp.Send(mail); | |
51 | } | |
52 | } | |
53 | } | |
54 | } | |
55 | } |