hello,
i am working on email functionality and recently i am using rad uploader to upload files and send to mails through smtp connection ,the problem is if i send notepad files it is uploading and sending to specified mailid ,but if we upload .pdf or .doc means pdf or wordformat files e.t.c it is not sending we are getting an error that file cannot found at path specified .i am sending a code block please reply soon
i am working on email functionality and recently i am using rad uploader to upload files and send to mails through smtp connection ,the problem is if i send notepad files it is uploading and sending to specified mailid ,but if we upload .pdf or .doc means pdf or wordformat files e.t.c it is not sending we are getting an error that file cannot found at path specified .i am sending a code block please reply soon
void SendEMail()
{
if (Session["UserID"] != null) //from home.aspx
{
newmailuserid = Convert.ToInt32(Session["UserID"]);
}
DbLayer objDB = new DbLayer();
System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
Message.To.Add(rdtxtTo.Text);
if (rdtxtCC.Text != string.Empty)
{
Message.CC.Add(rdtxtCC.Text);
}
Message.Subject = rdtxtSubject.Text;
Message.Body = rdtxtBody.Text;
System.Net.Mail.SmtpClient SmtpClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
SmtpClient.EnableSsl = true;
SmtpClient.Credentials = new System.Net.NetworkCredential("abc.hits.com", "hits@123");
System.Net.Mail.MailAddress FromEmail = new System.Net.Mail.MailAddress(TextBox1.Text);
Message.From = FromEmail;
try
{
System.Net.Mail.Attachment attachment;
foreach (UploadedFile file in RadUpload1.UploadedFiles)
{
try
{
string strFileName = null;
strFileName = System.IO.Path.GetFileName(file.FileName);
attachment = new System.Net.Mail.Attachment(Server.MapPath(strFileName));
Message.Attachments.Add(attachment);
}
catch
{
}
}
SmtpClient.Send(Message);