Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Error:Failure sending mail.
Pravin Ghadge
Dec 9 2010 7:23 AM
7.4k
Reply
Hi I have used gmail for sending mail localy which worked fine but when i uploaded the same file on server the "Failure sending mail."
My code is:
MailMessage
mm =
new
MailMessage
(
"
[email protected]
"
,
"
[email protected]
"
);
mm.Subject = txtSubject.Text;
mm.Body =
"Name: "
+ txtName.Text +
"<br /><br />Email: "
+ txtEmail.Text +
"<br />"
+ txtBody.Text;
if
(FileUpload1.HasFile)
{
string
FileName = System.IO.
Path
.GetFileName(FileUpload1.PostedFile.FileName);
mm.Attachments.Add(
new
Attachment
(FileUpload1.PostedFile.InputStream, FileName));
}
mm.IsBodyHtml =
true
;
SmtpClient
smtp =
new
SmtpClient
();
smtp.Host =
"smtp.gmail.com"
;
smtp.EnableSsl =
true
;
System.Net.
NetworkCredential
NetworkCred =
new
System.Net.
NetworkCredential
();
NetworkCred.UserName =
"
[email protected]
"
;
NetworkCred.Password =
"xxxxx"
;
smtp.UseDefaultCredentials =
true
;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
lblMessage.Text =
"Email Sent SucessFully."
;
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
problem on image retrieve from Database to Image control
Exception in Queue while removing an element ?