mail Attachment program in c#

V

vinodkus

MailMessage objMail = new MailMessage();
MailAttachment objAttach;// = new MailAttachment();
string strPath = "";
try
{
strPath =
System.IO.Path.GetFileName(File1.PostedFile.FileName);
}
catch (Exception ex)
{
Response.Write("Error ==>" + ex.Message);
}
objMail.From = txtFrom.Text;
objMail.To = txtTo.Text;
objMail.Subject = txtSubject.Text;
objMail.Body = txtBody.Text;
if (ddlPriority.SelectedValue == "Low")
{

objMail.Priority = MailPriority.Low;
}
else if (ddlPriority.SelectedValue == "Normal")
{
objMail.Priority = MailPriority.Normal;
}
else
{
objMail.Priority = MailPriority.Low;
}
objMail.Cc = txtCC.Text;
objMail.Bcc = txtBCC.Text;

objAttach = new MailAttachment(strPath);
objMail.Attachments.Add(objAttach);
SmtpMail.Send(objMail);

when i use it gives an error invalid attachments what is its cause?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top