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