User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,561 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,494 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 983 | Replies: 3
Reply
Join Date: Sep 2007
Posts: 28
Reputation: SiPexTBC is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
SiPexTBC SiPexTBC is offline Offline
Light Poster

Need help sending email

  #1  
Oct 22nd, 2007
I'm trying to send an email from my contact form using gmail, but i get a runtime error when try to send it.

Heres the code:

MailMessage email = new MailMessage();        
        email.From = new MailAddress(from);
        email.To.Add(new MailAddress(to));
        email.Subject = subject;
        email.Body = body;
        email.IsBodyHtml = false;        
        System.Net.NetworkCredential auth = new System.Net.NetworkCredential("username", "password");
        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
        smtp.EnableSsl = true;
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = auth;     
        smtp.Send(email);

Any help would be appreciated!

Thanks

SiPex
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help sending email

  #2  
Oct 23rd, 2007
change "smtp.gmail.com", 587" to "smtp.gmail.com", 465" and it should work.
Reply With Quote  
Join Date: Sep 2007
Posts: 28
Reputation: SiPexTBC is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
SiPexTBC SiPexTBC is offline Offline
Light Poster

Re: Need help sending email

  #3  
Oct 23rd, 2007
still getting

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help sending email

  #4  
Oct 23rd, 2007
well add the custom errors message they ask you to do to your web.config file. this way we can see what your error really is!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 5:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC