78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Net.Mail;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace NavigateurWeb
|
|
{
|
|
public partial class MailTo : Form
|
|
{
|
|
public MailTo()
|
|
{
|
|
InitializeComponent();
|
|
txt_from.Text= MailSettings.Default.mail;
|
|
txt_password.Text=MailSettings.Default.password;
|
|
txt_smtpserver.Text = MailSettings.Default.smtpServer;
|
|
|
|
}
|
|
|
|
private void btnSend_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnSend_Click_1(object sender, EventArgs e)
|
|
{
|
|
MailMessage message = new MailMessage();
|
|
SmtpClient SmtpServer = new SmtpClient(txt_smtpserver.Text);
|
|
MailSettings.Default.smtpServer = txt_smtpserver.Text;
|
|
message.From = new MailAddress(txt_from.Text);
|
|
message.To.Add(txt_to.Text);
|
|
message.Subject = txt_subject.Text;
|
|
message.Body = richTextBox1.Text;
|
|
SmtpServer.Port = 587;
|
|
SmtpServer.Credentials = new System.Net.NetworkCredential(txt_from.Text, txt_password.Text);
|
|
MailSettings.Default.mail = txt_from.Text;
|
|
MailSettings.Default.password = txt_password.Text;
|
|
SmtpServer.EnableSsl = true;
|
|
foreach (DataGridViewRow row in dgvAtach.Rows)
|
|
{
|
|
Attachment attachment = new Attachment(row.Cells[0].Value.ToString());
|
|
Console.WriteLine(row.Cells[0].Value.ToString());
|
|
message.Attachments.Add(attachment);
|
|
}
|
|
SmtpServer.Send(message);
|
|
|
|
}
|
|
|
|
private void pbAddAtach_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog ofd;
|
|
ofd = new OpenFileDialog();
|
|
ofd.CheckFileExists = true;
|
|
ofd.CheckPathExists = true;
|
|
ofd.Title = "Attachement";
|
|
if (ofd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
dgvAtach.Rows.Add(ofd.InitialDirectory + ofd.FileName);
|
|
}
|
|
}
|
|
|
|
private void pbDellAtach_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
foreach (DataGridViewRow row in dgvAtach.SelectedRows)
|
|
{
|
|
dgvAtach.Rows.RemoveAt(row.Index);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|