Error in attaching a file with the email in ASP.Net?
1- I decleare a public variable of type MailAttachment with name objMailAttachment.
2- I add a file field (HTML Control) to the form, named it fileAttach.
3- I write this code in send button Sub:
Dim mail As New MailMessage
mail.From = "itcenteronline@yahoo.com"
mail.To = txtmail.Text
mail.Subject = txtSubject.Text
mail.Body = txtBody.Text
If fileAttach.PostedFile.ContentLength <> 0 Then
objMailAttachment = New MailAttachment(fileAttach.PostedFile.FileName)
mail.Attachments.Add(objMailAttachment)
End If
SmtpMail.Send(mail)
So what is wrong?????????