C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

problem in sending mail though asp.net application


Posted Date: 20 Nov 2008      Posted By: meenakshi      Member Level: Silver     Points: 1   Responses: 5



hey i sending a mail through my asp.net application but i m not recieving mail in my mail box it is going into the queue folder
NAMESPACE used:System.Net;
System.Net.Mail;

CODE:
MailAddress f = new MailAddress(TextBox2.Text);
MailAddress t = new MailAddress(TextBox1.Text);
MailMessage msg = new MailMessage(f, t);
msg.IsBodyHtml = true;
msg.Subject = TextBox3.Text;
msg.Body = TextBox4.Text;
msg.Priority = MailPriority.High ;
string server;
server = ConfigurationManager.AppSettings.Get("localhost");
SmtpClient smtp = new SmtpClient("localhost");
smtp.Port = 25;
smtp.UseDefaultCredentials = true;
smtp.Send(msg);
Response.Write("mail sent");
plzzzzzzzzzz help me to sort out this problem.............
and tell me where is the problem





Responses

Author: Dharmaraj    20 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     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 2008Member Level: GoldRating: 2 out of 52 out of 5     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 2008Member Level: SilverRating: 2 out of 52 out of 5     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 2008Member Level: SilverRating: 2 out of 52 out of 5     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 2008Member Level: GoldRating: 2 out of 52 out of 5     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();
}
}



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : How to use usemap attribute and style attatribute in onload event
Previous : how to use style attribute in tag
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use