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
Jitendra Kumar
NA
189
23k
Please solve it my querry send email
Oct 26 2018 12:50 AM
Hi guys,
I am using this code in local then it is working but when I am running the same code on
online then it is giving error so please let me know what can I do for it
i have giving my querry below
protected
void
submit_Click(
object
sender, EventArgs e)
{
Sendmail(
"
[email protected]
"
,
"
[email protected]
"
,
"Contact Enquiry by New Customer"
,
"
[email protected]
"
,
"1234"
, name.Value , number.Value ,
email.Value , message.Value);
ClientScript.RegisterStartupScript(
this
.GetType(),
"alert"
,
"alert('Thank You! We will contact you shortly…');location.href ='contactus.aspx';"
,
true
);
//Response.Redirect("contactus.aspx");
}
public
static
void
Sendmail(
string
frm,
string
to,
string
subj,
string
logid,
string
passwd,
string
name1,
string
number1,
string
email1,
string
msg1)
{
try
{
MailMessage Msg =
new
MailMessage();
Msg.From =
new
MailAddress(frm);
Msg.Subject =
"New Customer Enquiry |"
+ email1 +
""
;
//string Body += "Dear Sir, <br/>";
Msg.Body +=
"<table width='600px' bgcolor='#f6f8f1' border='1' cellpadding='1' cellspacing='1'>"
;
Msg.Body +=
"<tr>"
;
Msg.Body +=
"<td align='center'><img src='http://ritzeggcafe.com/images/logo2.png' class='img-responsive' alt=''/></td>"
;
Msg.Body +=
"</tr>"
;
Msg.Body +=
"<tr>"
;
Msg.Body +=
"<td style='padding-left:15px;'>"
;
// Msg.Body = "<h1>Hello Brahmabull </h1><h3>from " + senderName2.Value + " </b><br/></h3>";
Msg.Body +=
"<h3>Dear <b> Sir </b>,</h3>"
;
Msg.Body +=
"<h4>Contact details are as mentioned below :</h4>"
;
Msg.Body +=
"<h3>Email Id: </h3><p>"
+ email1+
"</p>"
;
Msg.Body +=
"<h3>Contact No.</p>: </h3><p>"
+ number1 +
"</p>"
;
Msg.Body +=
"<h3>Customer Name: </h3><p>"
+ name1+
"</p>"
;
// Msg.Body += " <br/>";
Msg.Body +=
"<h3><b>Messege: </b></h3><p>"
+ msg1 +
"<br/></p>"
;
Msg.Body +=
" <br/>"
;
Msg.Body +=
"Regards By"
;
Msg.Body +=
" <br/>"
;
Msg.Body +=
"<h3><b>"
+ name1 +
"</b></h3>"
;
Msg.Body +=
"</td>"
;
Msg.Body +=
"</tr>"
;
Msg.Body +=
"<tr>"
;
Msg.Body +=
"<td align='center'><h5>Copyright 2017 .</h5></td>"
;
Msg.Body +=
"</tr>"
;
Msg.Body +=
"</table><br/>"
;
Msg.IsBodyHtml =
true
;
MailAddress objfrom =
new
MailAddress(frm);
MailAddress objto =
new
MailAddress(to);
Msg.Subject = subj;
Msg.From = objfrom;
Msg.To.Add(objto);
//Msg.Body = body.ToString();
SmtpClient smtp =
new
SmtpClient();
smtp.Host =
"smtp.gmail.com"
;
smtp.Port = 25;
smtp.Credentials =
new
System.Net.NetworkCredential(
"
[email protected]
"
,
"1234"
);
smtp.EnableSsl =
true
;
smtp.Send(Msg);
Msg =
null
;
}
catch
(SmtpFailedRecipientException ex)
{
//message(ex.Message);
}
}
}
Reply
Answers (
1
)
MVC Core Web Application two Models in a single View
why there is no master page for web application in asp.net