473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Problem sending mails

ThatThatGuy
449 Expert 256MB
Hello reader,,
This might be a very simple question, but what to just say about it, i'm facing it

Actually i'm developing a web App and i want email feature in that....
I'm sending mail from my development machine i.e localhost

This is the setting in web.config
Expand|Select|Wrap|Line Numbers
  1. <system.net>
  2.       <mailSettings>
  3.  
  4.         <smtp>
  5.           <network host="localhost" port="25" userName="reverso@gmail.com" password="somepassword" />
  6.         </smtp>
  7.       </mailSettings>
  8.     </system.net>
  9.  
and this is the code to send the email
Expand|Select|Wrap|Line Numbers
  1.         try
  2.         {
  3.             MailMessage mail = new MailMessage("from", "to","Some subject", "Mail Body");
  4.             SmtpClient sm = new SmtpClient("localhost", 25);
  5.             sm.Send(mail);
  6.             Page.Controls.Add(new LiteralControl("<script language='javascript'> alert('Mail Sent Successfully'); </script>"));
  7.  
  8.         }
  9.         catch (Exception rr)
  10.         {
  11.             Page.Controls.Add(new LiteralControl("<script language='javascript'> alert('" + rr.Message + "'); </script>"));
  12.         }
  13.  
Actually im facing problem sending mail plz someone verify this code
whether is it proper or not...
I'm getting failure sending mail error every time....
Plz help me with this it's urgent....
Aug 28 '09 #1
2 2746
ssnaik84
149 100+
- is mail server configured on your localhost?
- whats the exception?
- new MailMessage("from", "to" ......... "from", "to" should be email address not normal string
Aug 31 '09 #2
Frinavale
9,735 Expert Mod 8TB
@ThatThatGuy

In line 3 of your C# code you should be passing it the email address (maybe the one stored in the web.config) as the From parameter.

You also need to pass a valid email address as the To parameter.

If you're using the gmail account to send email messages then you're going to have to use a NetworkCredential Object to provide the credentials for your gmail account.

Check out this Quick Reference on how to send an email using .NET for more information.
Aug 31 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jayakumar | last post by:
HI, I am using System.web.mail class in my application to send mails. I am using SMTP server for the same. I can send mail to the intranet addresses, But when i send mails to Hotmail or other...
7
by: Lau | last post by:
I need to send 1000 emails from an asp.net website. Normally I would use System.Web.Mail.MailMessage() to send thru an SMTP server. But the large amount of emails results in a timeout. My server...
5
by: cashdeskmac | last post by:
I am writing a web application will will be hosted on a few peoples laptops as a local application. It will send e-mails once the user connects to the internet. How can I set up the "Mail.From"...
8
by: Michel Posseth [MCP] | last post by:
Hi does someone has experience with this ?? i have made a lot of apps in the past that were capable of sending e-mails the server i then talked to was a Linux SMTP server and it worked great ...
2
by: MJ | last post by:
I use the following code to send mails using php usinf PEAR package. When I run this code from command line using the command "php automaticMail.php" the code works fine. But when i run this...
0
by: ruchikagupta | last post by:
i m trying sending mails from the asp.net web application the code is running fine on another computer but if i run the same code on my system then it throws an exception "Failure Sending Mail" the...
2
by: joseph2000 | last post by:
Hi, I have problem with e-mails which are being send via System.Web.Mail.SmtpMail class but before describing the problem itself first I'd like to show shortly what I'm doing on the server. ...
2
by: softbreeze | last post by:
Operating systems: Windows 2003 Enterprise ASP.Net 2.0, IIS 6.0, *** SMTP is not installed *** I have a corporate network that has an SMTP server (10.254.3.30) on it. I have a subnet (10.5.42.0)...
2
by: srinivaspnv21 | last post by:
hi every one, plz help me out, i have to send mails from my asp.net page.... I have tried a code where mails are going only to gmail users the code is ... namespace: using System.Web.Mail;...
2
abdoelmasry
by: abdoelmasry | last post by:
Hi men i have big problem with microsoft exchange server 2003 i installed exchange server as main mail server to use it on in company i have static real ip address im sending and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.