protected void Btn_Send_Click(object sender, EventArgs e)
{
try
{
string to =Txt_To.Text;
string[] str = to.Split(';');
string from = Txt_From.Text;
string from_pwd = "12345678";
MailMessage mM = new MailMessage();
mM.From = new MailAddress(from);
foreach (string s in str)
{
mM.To.Add(s);
}
mM.Subject = Txt_Subject.Text;
mM.Body = Txt_message.Text;
mM.IsBodyHtml = true;
string s1 = "";
mM.Priority = MailPriority.High;
SmtpClient sC = new SmtpClient("mail.kumbhaj.com");
sC.UseDefaultCredentials = false;
sC.Port = 25;
if (FileUpload1.HasFile)
{
FileInfo f = new FileInfo(FileUpload1.FileName.ToString());
s1 = Guid.NewGuid().ToString();
s1 = "uploadfile/" + s1 + f.Extension;
FileUpload1.SaveAs(Server.MapPath(s1));
Attachment at = new Attachment(Server.MapPath(s1));
mM.Attachments.Add(at);
}
sC.Credentials = new System.Net.NetworkCredential(from, from_pwd);
sC.EnableSsl = false;
sC.Send(mM);
Lbl_Failled_Report.Text = "Message Successfully send.";
}
catch (Exception ex)
{
Lbl_Failled_Report.Text = "Message sending Failled!";
}
}
Wednesday, June 23, 2010
Sending E-mail with uploaded attachment
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment