TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
anjumathi kumar
NA
54
64k
Failure sending mail error
Aug 26 2011 2:39 AM
Hi this is my code
For sending an email
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
//using System.Net.Mail.SmtpClient;
//using System.Net.Mail.MailMessage;
namespace mailapp
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void sendMail(string toList, string fromlist, string ccList, string subject, string body)
{
try
{
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
MailAddress fromAddress = new MailAddress(fromlist);
message.From = fromAddress;
message.To.Add(toList);
if (ccList != null && ccList != string.Empty)
{
message.CC.Add(ccList);
}
message.Subject = subject;
message.IsBodyHtml = true;
message.Body = body;
smtpClient.Host = "127.0.0.1";
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential(txtfromadd.Text, txtpwd.Text);
smtpClient.Send(message);
}
catch (Exception ex)
{
lblmail.Visible = true;
lblmail.Text = ex.Message.ToString();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
//string fromadd = txtfromadd.Text;
string tocc = "
[email protected]
";
sendMail(txtToAddress.Text, txtfromadd.Text, tocc, txtSubject.Text, txtContent.Text);
}
}
}
I tried more possibilities to send email but am getting error failure sending email..Inner exception is unable to connect to the remote server
why what i want to do?i made any mistake in this?
Reply
Answers (
4
)
Loop through database table's cols
Response.write