hi every one
I'm having problem in mail attachment.I'm using the fileupload control to get the path of the file from the local machine.
It's giving the proper path but while attching the file from any folder its giving error "Invalid mail attachment".
Following is the code..
protected void sndmail_Click(object sender, EventArgs e)
{
objmail = new MailMessage();
objmail.From = txt_sender.Text;
objmail.To = txt_recipient.Text;
objmail.Cc = txt_cc.Text;
objmail.BodyFormat = MailFormat.Text;
objmail.Priority = MailPriority.High;
objmail.Subject = txt_sub.Text;
objmail.Body = txt_body.Text;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(objmail);
Response.Write("Mail send successfully...");
}
protected void attch_Click(object sender, EventArgs e)
{
string mypath = System.IO.Path.GetFullPath(FileUpload1.FileName);
MessageBox.Show(mypath);
MailAttachment attch = new MailAttachment(mypath);
objmail.Attachments.Add(attch);
}
Can you help me work out why I'm seeing this error?