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
  1. Home
  2. General Programming
  3. C#
  4. Sending mail using SMTP

Sending mail using SMTP

Scheduled Pinned Locked Moved C#
csharpvisual-studiodata-structureshelptutorial
7 Posts 5 Posters 0 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.
  • G Offline
    G Offline
    gr8tushar
    wrote on last edited by
    #1

    Hi All, here is a code snippet from my mail program. SmtpMail.SmtpServer = "localhost"; SmtpMail.Send (myemail); myemail is an object of MailMessage. If i run this program for the first time in Visual Studio there is an error saying CDO.Message is not accessible. When it runs all the mail messages are stored in c:\inetpub\mailroot\queue they do not reach there destinatin. They all are stored in my computer only. Please someone tell me how to solve this. WIll be eagrly waiting for the answer.

    M M H 3 Replies Last reply
    0
    • G gr8tushar

      Hi All, here is a code snippet from my mail program. SmtpMail.SmtpServer = "localhost"; SmtpMail.Send (myemail); myemail is an object of MailMessage. If i run this program for the first time in Visual Studio there is an error saying CDO.Message is not accessible. When it runs all the mail messages are stored in c:\inetpub\mailroot\queue they do not reach there destinatin. They all are stored in my computer only. Please someone tell me how to solve this. WIll be eagrly waiting for the answer.

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Can you post the details of how you're setting up myemail? Make sure the From property is set. Also, use a try/catch block to capture the exception and look for InnerExceptions. An InnerException may give more details as to the nature of the problem.

      G 1 Reply Last reply
      0
      • M Mike Ellison

        Can you post the details of how you're setting up myemail? Make sure the From property is set. Also, use a try/catch block to capture the exception and look for InnerExceptions. An InnerException may give more details as to the nature of the problem.

        G Offline
        G Offline
        gr8tushar
        wrote on last edited by
        #3

        Thanx for replying! i have used this code .. private void button1_Click(object sender, System.EventArgs e) { MailMessage myemail = new MailMessage(); myemail.From ="Tushar"; myemail.To ="a_tushar@hotmail.com"; myemail.Subject ="Test"; myemail.Body ="How are you "; System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send (myemail); } using this all my mails are stored on my computer only they are not being delivered at a_tushar@hotmail.com

        B 1 Reply Last reply
        0
        • G gr8tushar

          Hi All, here is a code snippet from my mail program. SmtpMail.SmtpServer = "localhost"; SmtpMail.Send (myemail); myemail is an object of MailMessage. If i run this program for the first time in Visual Studio there is an error saying CDO.Message is not accessible. When it runs all the mail messages are stored in c:\inetpub\mailroot\queue they do not reach there destinatin. They all are stored in my computer only. Please someone tell me how to solve this. WIll be eagrly waiting for the answer.

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          We answer you some days before. Look at those links and see how you should send email by C# and stop reposting the same question please. Mazy No sig. available now.

          1 Reply Last reply
          0
          • G gr8tushar

            Thanx for replying! i have used this code .. private void button1_Click(object sender, System.EventArgs e) { MailMessage myemail = new MailMessage(); myemail.From ="Tushar"; myemail.To ="a_tushar@hotmail.com"; myemail.Subject ="Test"; myemail.Body ="How are you "; System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send (myemail); } using this all my mails are stored on my computer only they are not being delivered at a_tushar@hotmail.com

            B Offline
            B Offline
            Broken God
            wrote on last edited by
            #5

            Well, the from should be an e-mail address.

            H 1 Reply Last reply
            0
            • B Broken God

              Well, the from should be an e-mail address.

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              This isn't his problem. As Mazdak said, we answer his question several days ago. His problem is that he hasn't configured the SMTP Virtual Server in the Internet Information Manager. I gave him pointers how to get started and told him to read the help, but he obviously hasn't.

              -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

              1 Reply Last reply
              0
              • G gr8tushar

                Hi All, here is a code snippet from my mail program. SmtpMail.SmtpServer = "localhost"; SmtpMail.Send (myemail); myemail is an object of MailMessage. If i run this program for the first time in Visual Studio there is an error saying CDO.Message is not accessible. When it runs all the mail messages are stored in c:\inetpub\mailroot\queue they do not reach there destinatin. They all are stored in my computer only. Please someone tell me how to solve this. WIll be eagrly waiting for the answer.

                H Offline
                H Offline
                Heath Stewart
                wrote on last edited by
                #7

                Once again I'll tell you that you're code isn't the problem - the problem is that you have NOT configured the SMTP Virtual Server at all or correctly. Again, go to Internet Information Manager in your Administrative Tools folder in the Control Panel and find the SMTP Virtual Server. You have to configure this to send mail using SMTP. It isn't setup by default but there's very little to do. Just read the help files which should be easy to understand. Once again - as Mazdak also said - this is not a problem with your code, hence quit posting it in the C# forum. It is a problem with your machine configuration of the SMTP Virtual Server. If you need additional help, go to http://support.microsoft.com[^]. It really isn't hard to configure, though.

                -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                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