| Author: Dharmaraj 20 Nov 2008 | Member Level: Diamond | Rating:  Points: 1 |
Hi, Check this link www.aspheute.com/english/20000918.asp Regards, Dharma
Regards, Dharma Editor,Mentor,MVM Try and fail but don't fail and try Me and DNS
|
| Author: Reddy 20 Nov 2008 | Member Level: Gold | Rating:  Points: 5 |
Hi friend,
Please use the following lines of code.
first you include the namespace as
using System.Web.Mail;
and in button click event write the following.
MailMessage mail = new MailMessage(); mail.To = txtTo.Text.ToString(); mail.From = txtFrom.Text; mail.Subject = txtSubject.Text; mail.Body = txtBody.Text.ToString(); mail.BodyFormat = MailFormat.Html; SmtpMail.Send(mail);
It is working fine. just now i tested, and sending.
Good luck reddy.sankar1983@gmail.com
|
| Author: meenakshi 21 Nov 2008 | Member Level: Silver | Rating:  Points: 3 |
thanks mr reddy but this code is giving error
The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for me@gmail.com
plz help
|
| Author: Legend 21 Nov 2008 | Member Level: Silver | Rating:  Points: 5 |
Please use the following lines of code.
first you include the namespace as
using System.Web.Mail;
and in button click event write the following.
MailMessage mail = new MailMessage();
mail.To = txtTo.Text.ToString(); mail.From = txtFrom.Text;
mail.Subject = txtSubject.Text; mail.Body = txtBody.Text.ToString();
mail.BodyFormat = MailFormat.Html;
SmtpMail.Send(mail);
It is working fine. just now i tested, and sending.
|
| Author: puneet malviya 06 Dec 2008 | Member Level: Gold | Rating:  Points: 6 |
Hi....... Hi..
Using system.web.mail;
private void SendMail() { try { MailMessage m_newmail = new MailMessage(); SmtpClient s_client = new SmtpClient(); string attachfile=string.Empty; Attachment m_attach; string attachfile1=string.Empty; string strdir = string.Empty; MailAddress fromAdr = new MailAddress(txtEmail.Text); m_newmail.From = fromAdr;
string strMailId = System.Configuration.ConfigurationManager.AppSettings["MailId"].ToString(); m_newmail.To.Add(strMailId); m_newmail.Subject = "About Enquiry";
StringBuilder MailBody = new StringBuilder(); MailBody.Append("Name :" + txtName.Text.Trim() + "<br/>"); MailBody.Append("Designation :" + txtDesgntn.Text + "<br/>"); MailBody.Append("Company Name :" + txtCoName.Text + "<br/>"); MailBody.Append("Address :" + txtAddress.Text + "<br/>"); MailBody.Append("Pin :" + txtPin.Text + "<br/>"); MailBody.Append("Country :" + txtCountry.Text + "<br/>"); MailBody.Append("Telephone :" + txtTel1.Text + "-" + txtTel2.Text + "-" + txtTel3.Text + "<br/>"); MailBody.Append("Fax :" + txtFax.Text + "<br/>"); MailBody.Append("Like to comment on :" + cmbComment.SelectedValue + "<br/>"); MailBody.Append("Suggestions :" + txtSuggestions.Text + "<br/>"); MailBody.Append("Please tell us what you are looking for in enquiry :" + chklstEnquiry.SelectedValue + "<br/>"); MailBody.Append("Additional Information :" + txtAdditionalInfo.Text + "<br/>"); MailBody.Append("How did you here about us :" + cmbSelect.SelectedValue + " <br/>");
m_newmail.Body = MailBody.ToString(); m_newmail.IsBodyHtml = true;
if(fileName.HasFile) { attachfile = Path.GetFileName(fileName.PostedFile.FileName); fileName.PostedFile.SaveAs(Server.MapPath(attachfile));
m_attach = new Attachment(Server.MapPath(attachfile));
m_newmail.Attachments.Add(m_attach); attachfile1 = attachfile; } s_client.Host = "localhost"; s_client.UseDefaultCredentials = true; s_client.Send(m_newmail);
ClientScript.RegisterClientScriptBlock(this.GetType(), "Hi!", String.Format("alert('An email has successfully been sent to {0}');", m_newmail.To), true); ClearAll();
m_newmail.Dispose();
if (attachfile1 != null) { File.Delete(Server.MapPath(attachfile1)); } } catch (Exception ex) { ClearAll(); } }
|