Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Net;
- using System.Net.Mail;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace תוכנה_מצויינת_למיקמק_עובדת
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using System.Net;
- using System.Net.Mail;
- class Program
- {
- static void Main()
- {
- string smtpAddress = "smtp.mail.yahoo.com";
- int portNumber = 587;
- bool enableSSL = true;
- string emailFrom = "oded4664@gmail.com";
- string password = "*******";
- string emailTo = "oded4664@gmail.com";
- string subject = "Hello";
- string body = "Hello, I'm just writing this to say Hi!";
- using (MailMessage mail = new MailMessage())
- {
- mail.From = new MailAddress(emailFrom);
- mail.To.Add(emailTo);
- mail.Subject = subject;
- mail.Body = body;
- mail.IsBodyHtml = true;
- // Can set to false, if you are sending pure text.
- mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
- mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));
- using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
- {
- smtp.Credentials = new NetworkCredential(emailFrom, password);
- smtp.EnableSsl = enableSSL;
- smtp.Send(mail);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement