Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. how to send mail from my c# windows application [modified]

how to send mail from my c# windows application [modified]

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphelpcomsysadmintutorial
9 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Balaji_Reddy
    wrote on last edited by
    #1

    hi everyone,i'm trying to develop an application to send an e-mail from my c# windows application here i'm tis namespace using System.Net.Mail; and its my code::::: :confused: private void button1_Click(object sender, EventArgs e) { try { SmtpClient client = new SmtpClient("192.168.1.15", 808); MailAddress from = new MailAddress("a@live.com"); MailAddress to = new MailAddress("d@live.com"); MailMessage mail = new MailMessage(from,to); mail.Body = textBox1.Text; mail.Subject = " hi da "; client.Send(mail); } catch (SystemException se) { MessageBox.Show(se.ToString()); } finally { } -------------------------------------------------- this is ma code but its work but i'm getting run time error like " failure sending mail, unable to connect to remote server" in smtpclient class i have given ip address as my host and port id..... pls help me to resolve tis error

    modified on Friday, April 16, 2010 4:23 AM

    M 1 Reply Last reply
    0
    • B Balaji_Reddy

      hi everyone,i'm trying to develop an application to send an e-mail from my c# windows application here i'm tis namespace using System.Net.Mail; and its my code::::: :confused: private void button1_Click(object sender, EventArgs e) { try { SmtpClient client = new SmtpClient("192.168.1.15", 808); MailAddress from = new MailAddress("a@live.com"); MailAddress to = new MailAddress("d@live.com"); MailMessage mail = new MailMessage(from,to); mail.Body = textBox1.Text; mail.Subject = " hi da "; client.Send(mail); } catch (SystemException se) { MessageBox.Show(se.ToString()); } finally { } -------------------------------------------------- this is ma code but its work but i'm getting run time error like " failure sending mail, unable to connect to remote server" in smtpclient class i have given ip address as my host and port id..... pls help me to resolve tis error

      modified on Friday, April 16, 2010 4:23 AM

      M Offline
      M Offline
      Michel Godfroid
      wrote on last edited by
      #2

      Do you have an smtp server running at 192.168.1.15:808 ? probably not. You should use the smtp relay host that your isp has given you. (use the fqdn, not the ip-address) If you don't have mail at an isp, this won't work. (live.com does not provide smtp relay services). Also, your isp may limit the from: address, and may require authentication when sending mail.

      B 1 Reply Last reply
      0
      • M Michel Godfroid

        Do you have an smtp server running at 192.168.1.15:808 ? probably not. You should use the smtp relay host that your isp has given you. (use the fqdn, not the ip-address) If you don't have mail at an isp, this won't work. (live.com does not provide smtp relay services). Also, your isp may limit the from: address, and may require authentication when sending mail.

        B Offline
        B Offline
        Balaji_Reddy
        wrote on last edited by
        #3

        hi their,u have told me to use fqdn instead of smtp class n also u have mentioned tat "live.com does not provide smtp relay services" then which mail portal does support to send mails without any limitation or minimum limitation... how do i find fqdn....? could u give the exact coding to accomplish my task?

        M 1 Reply Last reply
        0
        • B Balaji_Reddy

          hi their,u have told me to use fqdn instead of smtp class n also u have mentioned tat "live.com does not provide smtp relay services" then which mail portal does support to send mails without any limitation or minimum limitation... how do i find fqdn....? could u give the exact coding to accomplish my task?

          M Offline
          M Offline
          Michel Godfroid
          wrote on last edited by
          #4

          fqdn means fully qualified domain name. Try Google if you don't understand a word. What you're looking for is an 'open smtp relay' (look it up before replying). Technically not illegal, but if you find one, your mail will probably be blocked by the recipient's ISP. Are you trying to get into the spam business? You will have to set up your own smtp server if you want to send mail without limitations, but if you start spamming, expect 1) Your Internet account to be closed down by your ISP 2) If you're really good at it, a visit from the Feds. (CAN-SPAM act of 2003). If your intentions are pure, have a look at this list: http://www.iopus.com/guides/bestpopsmtp.htm[^]

          B 1 Reply Last reply
          0
          • M Michel Godfroid

            fqdn means fully qualified domain name. Try Google if you don't understand a word. What you're looking for is an 'open smtp relay' (look it up before replying). Technically not illegal, but if you find one, your mail will probably be blocked by the recipient's ISP. Are you trying to get into the spam business? You will have to set up your own smtp server if you want to send mail without limitations, but if you start spamming, expect 1) Your Internet account to be closed down by your ISP 2) If you're really good at it, a visit from the Feds. (CAN-SPAM act of 2003). If your intentions are pure, have a look at this list: http://www.iopus.com/guides/bestpopsmtp.htm[^]

            B Offline
            B Offline
            Balaji_Reddy
            wrote on last edited by
            #5

            i saw about fqdn in google ... but my aim is not to get into spam business...its just for my learning only actually i wanna to develop a application just like outlook n i'm student so i'm wanna to learn it. i wan code for my gmail account....once if i go through tat sample code then i ll become much clear...could u post any sample code?if yes pls post it soon because i'm eager to learn it

            M 1 Reply Last reply
            0
            • B Balaji_Reddy

              i saw about fqdn in google ... but my aim is not to get into spam business...its just for my learning only actually i wanna to develop a application just like outlook n i'm student so i'm wanna to learn it. i wan code for my gmail account....once if i go through tat sample code then i ll become much clear...could u post any sample code?if yes pls post it soon because i'm eager to learn it

              M Offline
              M Offline
              Michel Godfroid
              wrote on last edited by
              #6

              How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^]

              B 2 Replies Last reply
              0
              • M Michel Godfroid

                How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^]

                B Offline
                B Offline
                Balaji_Reddy
                wrote on last edited by
                #7

                :-D hey thanks friend... its works now..now i realized my problem.. actually i was sending from firewall enabled machine ..after i gone through tat code n its commands i turn off my proxy n i sent mail then i worked ...once again tanks michal:thumbsup:

                1 Reply Last reply
                0
                • M Michel Godfroid

                  How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^]

                  B Offline
                  B Offline
                  Balaji_Reddy
                  wrote on last edited by
                  #8

                  i was working in proxy enabled machine.after i turn off it then it works but again i got different run time error n the exception was "smtp requires secure connection or client was not authenticated".it sent few failure notice to my mail id. pls help me to resolve tis problem:confused:

                  M 1 Reply Last reply
                  0
                  • B Balaji_Reddy

                    i was working in proxy enabled machine.after i turn off it then it works but again i got different run time error n the exception was "smtp requires secure connection or client was not authenticated".it sent few failure notice to my mail id. pls help me to resolve tis problem:confused:

                    M Offline
                    M Offline
                    Michel Godfroid
                    wrote on last edited by
                    #9

                    You will probably have to turn on SSL (secure sockets layer) to get access to server. Turn on the EnableSsl property of your SmtpClient object. You may also have to select another port to send on. Talk to whoever is administering the smtp server, or read any documentation for this smtp server. If you already can send mail through this server, from another program (outlook, or windows mail, or whatever), lookup the connection parameters in that program. Here is full example of mail client that uses SSL: http://www.codeproject.com/Articles/66257/Sending-Mails-in-NET-Framework.aspx[^]

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups