Problem in sending mail using system.net.mail

I am using C# and ASP.Net2.0 for sending mail. But my problem is it is not being sent. I am not being able to understand it. I am using my gmail account for it. I am using System.Net and System .Net.Mail for sending the same. But i am getting the error ''Failure Sending Mail. Cannot connect to the server" . I have internet connection. Plz help me. It's urgent. I am attaching my code.

 

MailMessage mailMsg = new MailMessage();MailAddress ma = new MailAddress(username@gmail.com);

mailMsg.From = ma;

mailMsg.To.Add(s);

mailMsg.Subject =
"Your way2k.com account password information";

mailMsg.IsBodyHtml = true;

mailMsg.Body = "Your Account Information: \n\t\t UserName/Email: " + TxtBxEmail.Text.Trim() +"\n\t\t Password:" + ds.Tables["UserPassword"].Rows[0].ItemArray[0].ToString().Trim();

 

mailMsg.Priority = MailPriority.High;

SmtpClient smtpclnt = new SmtpClient();

smtpclnt.Host = "smtp.gmail.com";

NetworkCredential nc = new NetworkCredential("username", "password");

//smtpclnt.Port = 25;

smtpclnt.UseDefaultCredentials = false;

smtpclnt.Credentials = nc;

smtpclnt.EnableSsl =
false;

smtpclnt.Send(mailMsg);

flag = 1;


Web Developer
Pune,India
0
smartymca
1/24/2009 2:48:31 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
920 Views

Similar Articles

[PageSpeed] 26

 hi smartymca,

follow this link for yr anwser...

1 .http://ramanisandeep.wordpress.com/2008/10/07/send-email-in-aspnet-20/

2. http://dotnetguts.blogspot.com/2006/10/send-email-from-gmail-in-aspnet-20.html

3. http://www.shabdar.org/send-email-using-gmail-account-asp-net-csharp.html

 hope this links will help u..

Happy Programming.....

 


Happy Programming

Sandeep M Ramani

(http://ramanisandeep.wordpress.com)
0
sandy060583
1/24/2009 3:15:49 PM
Reply:

Similar Artilces:

Problem with difference between System.Web.Mail and System.Net.Mail in using attachments
I have a web .Net app which sends emails with attachments.  After the email is sent I clean up aftermyself and delete the attachments from disk.   In upgrading to .Net 2  I changed the email logic from using system.web.mail to system.net.mail  (of course vs is telling me system.web.mail is obsolete).In .Net 1.1,  the files deleted with no problem but in .Net 2 when I attempt to delete  I receive The process cannot access the file ...' because it is being used by another process. If I change the code back to using system.web.mail I can delete the file...

Why do Sending SMTP Authenticated E-mail succeed using SmtpMail.Send() function but fail using SmtpClient.send() function ? Bugs in System.Net.Mail.SmtpClient when send a Authenticated E-mail?
I click btnOK button, the email can send OK, but click btnFail button,  the following error is displayed! why ? you can test the section code. The SMTP, username, password are valid!  Many thanks! "Syntax error, command unrecognized. The server response was: authentication failed,decode user password error" I have tested some other SMTP, somes is OK. I think there are some bugs with System.Net.Mail.SmtpClient when send a Authenticated E-mail with some SMTP!   //------------------------------------------.ASPX Code----------------------------------------...

Sending Mail Using System.Net.Mail with out using User credentials
HI, I have an application where in i send mails based on some condition, the user is already authenticated, so i need not check the User Credentials.Right now this is how the piece lokks:- mailClient.Credentials = new NetworkCredential(USERID, USER_PWD,DOMAIN); I want to send the mail, with out validating the user credentials, Can i skip the above line. Please post aqlong with the sample code.   Thanx in Advance. Anil Kumar.   I think you cannot skip. but store user credentials in session variables after login and then pass.If this post was useful to you, please mark it as...

System.web.mail to System.net.mail
I converted a asp.net web app from VS 2003 to VS 2005. i now get error message when i build it  stating system.web.mail  is obsolute,  use system.net.mail i redefine to system.net.mail but now i get other error message such as smtpMail does not exist in the current context. cannot implicitly convert type string to System.Net.Mail.MailAddress   so System.Web.Mail want work in ASP.net web app convert to VS 2005 running on framework 2.0?           because if i change to System.Net.Mail  i am ...

.net 2 beta 2 - System.Net.Mail
Hi guysI'm using the System.Net.Mail namespace in .net version 2, beta 2, to send out some HTML formatted e-mails.However, for some reason when the e-mail are sent out some of the full stops from the e-mail are removed.For example, part of the e-mail contains this code<img src="http://www.avonandsomerset.police.uk/images/grey_box_bottom.gif" alt="">But this is what the code is like when the e-mail source code is viewed<img src="http://www.avonandsomerset.police.uk/images/grey_box_bottomgif" alt="">Is this a known bug in beta 2? If so, where can I view a list of known bugs an...

need help: sending mail using system.net.mail
hi thr.. i am some help urgently.. i need to send mail using asp.net the cs code is          System.Net.Mail.MailMessage MyMail = new System.Net.Mail.MailMessage();        SmtpClient SmtpMail = new SmtpClient();            try            {                MyMail.From = new MailAddress("balu.naren@gmail.com");  &n...

Help for Visual web dev isolate system.web.mail to system.net.mail
Hi all,  I'm new user to visual web developer express software. Laterly i found this application isolate quite some of the component namespace, like system.web.mail to net.mail. I not well understand how system.net.mail functional?? Does it act same as system.web.mail?? My coding below: change system.web.mail to system.net.mail which causing a lot error... *****Can anybody correct me or advise me how to make this code work in system.net.mail?????? <%@import Namespace="System.net.Mail" %> <script runat="server">    Public FromAddress As String = "" .......

How to send Mail using System.Net.Mail outside the company network?
Hi All, I am trying to send mail to my (jay.khanpara@gmail.com) account, but its not going and throwing error like "Mailbox unavailable. The server response was: <jay.khanpara@gmail.com> No such user here". Its working fine if i will send to our company ids. Please help me out. Code: SmtpClient smtp = new SmtpClient();smtp.Host = "mail.companyname.com"; smtp.Port = 25; //smtp.Credentials = CredentialCache;MailMessage msg = new MailMessage();MailAddress from = new MailAddress(txtFrom.Text); msg.Sender = from; msg.From = from;  string[] tos = txtTo.Text...

What is the maximum size of attachement in sending mail using system.net.mail?
I am able to send mail with attachement using System.Net.Mail. But I want to know the maximum size limit of aatchement. Thanks, Prashant It depends on your smtp server settings  MAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Site : ASPSnippets Hello Mudassar Khan, Thank you very much for your reply.  Where and how to set this setting in my SMTP server???? And one more thing I want to know that there is any limit of the message body size or message size that can be sent using system.net.mail???????   Thanks, P...

difference between System.Web.Mail and System.Net.Mail
What is difference between System.Web.Mail and System.Net.Mail  namespace?What is use of both ? System.Web.Mail was in .NET Framework v1.1System.Net.Mail is in .NET Framework v2.0 and greaterSame use, although there is more functionality in System.Net.Mail since it is a later version of the framework. Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!  What All-Star said. I assume the reason it was moved to a different namespace is because the internet is actually a suite of technologies: e-mail, ftp, http (web), etc. E-mail and...

Migrating from System.web.mail to System.net.mail
Hi Every1,I've recently used the System.web.mail to send mail, using the IIS's smtp server.Doing this, i didn't really need to do anything in the web.config file or give any special parameters to the client. It just assumed i was working with my very own smtp service that came with the IIS and everything worked fine.Now i migrated to System.net.mail and now i need to insert my smtp service's host location under <system.net> in the web.config file.However, i don't know what to write there so the client will use my smtp sevice (host="localhost" doesn't work)can any1 help me on this one?t...

switching from system.web.mail to system.net.mail
I have been converting my code from system.web.mail to system.net.mail.  I have been able to convert the to, from, cc, and message body to the new format easily but...my question is how do i convert this into system.net.mail format?SmtpMail.SmtpServer = "server";                SmtpMail.Send(mail);Would this be the solution?SmtpClient client = new SmtpClient("server");                client.Send(mail); Here's a full example of how to per...

Working with System.Web.Mail but not with System.Net.Mail
Hi, i am having trouble sending e-mails using System.Net.Mail namespace while there is no problem with System.Web.Mail. I am  using remote smtp server with no authentication.  My code as shown below:1 try2 {3 MailMessage message = new MailMessage();4 message.BodyFormat = MailFormat.Html;5 message.To = "admin@mydomain.com";6 message.From = "test@mydomain.com";7 message.Subject = "Test Smtp";8 message.Body = "TestMail 123";9 10 SmtpMail.SmtpServer = "mail.mysmt...

System.Web.Mail vs System.Net.Mail
Hi AllI was using System.Web.Mail in an application on our test server.  That worked fine.  I never had to specify a server or change any settings.  It just works.  Whatever settings the server has set up are used.  This is great.I saw that System.Web.Mail has been deprecated, so I'm trying to use System.Net.Mail.  I'm having a problem.  Net.Mail doesn't use whatever settings Web.Mail used.  I can't send e-mail with Net.Mail.  I see several people use the web.config file to set the server up, but I can't get that to work. I jus...

Web resources about - Problem in sending mail using system.net.mail - asp.net.web-forms

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

The problem with using infrastructure to stimulate an economy
The immediate boost to the economy from infrastructure stimulus spending is minimal, while the cost for any new jobs it creates can be huge

The problem with “bringing the country together”
... our country needs is to reject the very premise of politics. The disparate factions in the United States don’t even agree on what our problems ...

Apple confirms bug that makes the iPhone’s most frustrating problem even more frustrating
... as and satisfied as they are though, we doubt any iPhone user would make the claim that his or her handset is perfect. No, iPhones have problems ...

Silicon Valley bigwig explains why he's solving what seems like a rich person's problem
... implied criticism is something that Silicon Valley entrepreneurs hear a lot: That they're not really solving the world's most important problems, ...

More problems for Twitter
Third sporadic outage in five days hits social media giant

The problem with Chinese data...
John Rutledge, Safanad chief investment strategist, shares his thoughts on China's GDP and real economic growth. And Mike Santoli, CNBC senior ...

‘Degrassi: Next Class’: “The Drugs Have Changed But The Problems Are Still The Same”
Degrassi is known for tackling the complex issues that high school students face. Subjects such as teen pregnancy, drugs, school shooting and ...

Fujitsu wants to fix Japan's deer problem with software
Fujitsu is teaming up with a Japanese forest research institute to learn how animal populations grow. The pair will look into Sika deer, a creature ...

Free Basics, net neutrality, and the problem with charity
This must have been a pretty bad year for Mark Zuckerberg. He thought he'd be a hero, but now he's a pariah. Why?

Resources last updated: 1/19/2016 2:28:52 PM