Merhabalar, c#'da mail gönderme sırasında dosya eklemek istiyorum. Fakat 1den fazla dosya yollayamıyorum, acil yardıma ihtiyacım var.
KODLAR :
mail gönderme butonu :
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress(textBox3.Text);
mail.To.Add(textBox5.Text);
mail.Subject = textBox6.Text;
mail.IsBodyHtml = true;
mail.Body = textBox2.Text;
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential(textBox3.Text, textBox4.Text);
smtpServer.EnableSsl = true;
mail.Attachments.Add(new Attachment(file));
smtpServer.Send(mail);
MessageBox.Show("Mail yollandı");
}
catch
{
}
}
dosya seçme butonu :
try
{
OpenFileDialog dosyasec = new OpenFileDialog();
dosyasec.Title = "Eklenecek dosyayı seçiniz...";
dosyasec.ShowDialog();
file = dosyasec.FileName;
listBox1.Items.Add(file.ToString());