Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
code i am using to attach multiple file

C#
private void button4_Click(object sender, RoutedEventArgs e)
      {
          Microsoft.Win32.OpenFileDialog filedialog = new
          Microsoft.Win32.OpenFileDialog();
          filedialog.Filter = "Zip Files|*.zip";
          if (flag == 0)
          {
              bool b = (bool)filedialog.ShowDialog();
              if (b == true)
              {
                  attach.Text = filedialog.FileName+";";
              }
              flag++;
          }
          else
          {
              TextBox vv = new TextBox();
              bool b = (bool)filedialog.ShowDialog();
              if (b == true)
              {
                  attach.Text += filedialog.FileName + ";";
              }
          }


      }
to send files

C#
foreach (string m in attach.text.Split(';'))
                 {
                     
                     mail.Attachments.Add(new Attachment(m));

                 }


i am getting error that empty file cannot be attached.

pleae help thanks in advance
Posted
Updated 6-Feb-13 17:59pm
v3
Comments
Tejas Vaishnav 6-Feb-13 23:54pm    
Have you check your files which are attached using this code.? the error seems like while you are attaching your file at that time the file is not proper, that's why it is not able to attached with your mail and throws error.
vikrant vaibhav 6-Feb-13 23:56pm    
yes those are absolutely fine.
Kishor Deshpande 7-Feb-13 0:01am    
Getting error? Can you please share some exception message??
vikrant vaibhav 7-Feb-13 0:06am    
system.argumentexception:the parameter filename cannot be empty string
vikrant vaibhav 7-Feb-13 0:07am    
this exception comes after debugging this line

mail.Attachments.Add(new Attachment(m));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900