-1
have a doubt my program consists of sending email with attachments but sometimes when I don’t want to send an email with attachments gives me an error
Anyone can help?
I can send email with attachments without problems but no attachments does not work
code:
private void button4_Click(object sender, EventArgs e){
SmtpClient cliente = new SmtpClient();
MailMessage msg = new MailMessage();
msg.Attachments.Add(new Attachment(Anexostxt.Text));
msg.Attachments.Add(new Attachment(anexos2.Text));
}
private void button6_Click(object sender, EventArgs e){
OpenFileDialog dlg = new OpenFileDialog();
if(dlg.ShowDialog()==DialogResult.OK){
string picpath = dlg.FileName.ToString();
Anexostxt.Text = picpath;
}
}
Additional information error: The filename parameter cannot be an empty string.
From the picture it’s obvious that
Anexostxt.Text
is empty, why? Just seeing the code. Show the code snippet whereAnexostxt.Text
is set.– rubStackOverflow
this print helps?
– Fabio Gonçalves
No, from what I understand,
Anexostxt.Text
refers to the attached file. So where are you setting this method? Something like this:Anexostxt.Text = "c:\meuanexo.txt"
– rubStackOverflow
Prefer to put code and not images. Put the exception message and the stack trace of the same.
– Omni
the message is : "The filename parameter cannot be an empty string. r nName of parameter: filename"}
– Fabio Gonçalves