473,587 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

send mail in asp.net(C#)2008

10 New Member
Hello,
This is venkat,
I was trying to send the email using the following codes but error occurs everytime can you fix this.
Expand|Select|Wrap|Line Numbers
  1. using System.Data;
  2. using System.Linq;
  3. using System.Web;
  4. using System.Web.Security;
  5. using System.Web.UI;
  6. using System.Web.UI.HtmlControls;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Xml.Linq;
  10. using System.Net.Mail;
  11.  
  12.     MailMessage mail = new MailMessage();
  13.         mail.To = ToTextBox.Text;
  14.         mail.From=FromTextBox.Text;
  15.         mail.CC=CcTextBox.Text;
  16.         mail.Subject=SubTextBox.Text;
  17.         mail.Body=MsgTextBox.Text;
  18.         System.Net.Mail.SmtpClient SmtpServer = "localhost";
  19.         SmtpServer.Send(mail);
  20.  
is this correct format? pls send if any correct coding for that? also what are the things should declare in the top?
Apr 2 '08 #1
4 1489
GayathriP
17 New Member
The Port No is not specified to send the email.
It can be done by

SmtpServer.Port = <PortNo>;
Apr 3 '08 #2
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
System.Net.Mail .SmtpClient SmtpServer = "localhost" ;

since you are creating a SmtpClient object you have to create a new one

i.e.
System.Net.Mail .SmtpClient SmtpServer = new System.Net.Mail .SmtpClient("19 2.168.0.1");
its better to send an ip address to it.
i havent tested it using localhost. (im not sure of that), and yes you may also have to specify the port if it is not on the default smtp port which i thing is 25
Apr 3 '08 #3
pskvenkat
10 New Member
System.Net.Mail .SmtpClient SmtpServer = "localhost" ;

since you are creating a SmtpClient object you have to create a new one

i.e.
System.Net.Mail .SmtpClient SmtpServer = new System.Net.Mail .SmtpClient("19 2.168.0.1");
its better to send an ip address to it.
i havent tested it using localhost. (im not sure of that), and yes you may also have to specify the port if it is not on the default smtp port which i thing is 25

Can you tel how can i find the smtp server port number?
Apr 3 '08 #4
Plater
7,872 Recognized Expert Expert
Can you tel how can i find the smtp server port number?
It probably is 25. The real problem was your incorrect "constructo r" calling of the SmtpClient class
Apr 3 '08 #5

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

Similar topics

11
1973
by: Ken Fine | last post by:
I am using VS.NET 2008 and like it a lot. One of the very few things I don't like is a bug that seems to spawn literally thousands of   strings, one after the other, on design view changes. Sometimes I will end up with as many as 30,000 of them. I have to do a "Replace" which is slower than I'd like. This is slowing down my work a lot. This...
4
1548
by: bj7lewis | last post by:
I am currently C++/Win32/MFC & C# programmer using VS.NET 2002 and jumped into VS.NET 2003 but that was a waste so I skipped VS.NET 2005 cause buying VS.NET 2003. Now after checking out VS.NET 2008 Beta2 I think VS.NET 2008 is worth the upgrade. But I want to hold off(five+ years depending on features) on more further upgrades OSs & ISEs cause...
4
1180
by: =?Utf-8?B?dGhlamFtaWU=?= | last post by:
Can NET 2008 run side by side with NET 2005? -- Regards, Jamie
1
1379
by: kunalvumca200519 | last post by:
I would like to know about wcx, wpx, wax in vb.net 2008 and what is XAML? Please reply me...
11
2707
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hello, I have just installed VISTA Enterprise and VS.NET 2008. When pressing F5 to debug my test ASP.NET website, IE 7 display the message "Internet Explorer cannot display the webpage". The local URL that VS.NET 2008 generates is http://localhost:49705/aaa/Default.aspx. In IIS7 Manager, ASP.NET V2.0… is "Allowed" in the ISAPI and CGI...
2
1824
by: 14All2C | last post by:
Experts I've heard that its supposed to be easy to use VB.Net objects directly with JavaScript using ASP.Net and Ajax in Visual Studio 2008. I can't find any info anywhere on how to do this, and its proving to be not as simple as it was stated to me; but the boss has asked me to investigate this 'major gain is VS 2008'. I'd like to...
3
974
by: Cirene | last post by:
It seems like the VS.net 2008 editor is slow and buggy. Have you found this to be the case? A few times I am working and all of a sudden all my images are stretched funny. I find out that behind the seens it modified the img tag width in my css file. Also, when dealing in split view with a page that is using a master page, it seems...
4
2450
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I suspect some permissions problem. I'm running VS.NET 2008 in Vista. Symptoms and observations: * ASP.NET's native ImageMap and Image controls work...
2
1272
by: JDeats | last post by:
I apologize if this question is answered on MSDN, I searched and could not find a clear answer: I have a Windows XP PC that has VS.NET 2005 Professional installed. So far my VS.NET 2008 development has been done on a seperate Windows Vista PC. I would like to maintain VS.NET 2005, because I need to maintain VS.NET 2005 format for certain...
1
1090
progdoctor
by: progdoctor | last post by:
Guyz... can u tell me the advantage of asp.net 2008 cuz we want to migrate from asp.net 2005 to 2008.In 2005 we use infragistics as controls component. Do visual studio 2008 have components like that?? Thanks for the info...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.