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. how can i send emails automatically in asp.net using C# code

how can i send emails automatically in asp.net using C# code

Scheduled Pinned Locked Moved C#
csharpasp-nethelpquestion
6 Posts 3 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.
  • R Offline
    R Offline
    Rajeshwar Code Developer
    wrote on last edited by
    #1

    hello every one... plzz.. help me .. actually i want 2 send emails automatically at a particular time how can i do this ..plzz..help me...

    thanks 2 all..

    A S 2 Replies Last reply
    0
    • R Rajeshwar Code Developer

      hello every one... plzz.. help me .. actually i want 2 send emails automatically at a particular time how can i do this ..plzz..help me...

      thanks 2 all..

      A Offline
      A Offline
      Albu Marius
      wrote on last edited by
      #2

      Use a service (windows or web) with a timer. When the timer reaches the particular time needed send the emails by using the System.Net.Mail.MailMessage class.

      I am fighting against the Universe... Reference-Rick Cook

      R 1 Reply Last reply
      0
      • A Albu Marius

        Use a service (windows or web) with a timer. When the timer reaches the particular time needed send the emails by using the System.Net.Mail.MailMessage class.

        I am fighting against the Universe... Reference-Rick Cook

        R Offline
        R Offline
        Rajeshwar Code Developer
        wrote on last edited by
        #3

        but how can i do ..plz..send me code brother......if u have or give me any sugession..

        thanks 2 all..

        A 1 Reply Last reply
        0
        • R Rajeshwar Code Developer

          but how can i do ..plz..send me code brother......if u have or give me any sugession..

          thanks 2 all..

          A Offline
          A Offline
          Albu Marius
          wrote on last edited by
          #4

          I have used this approach in a project of mine . I created a windows service and by default this will give you 2 event handlers : OnStart & OnStop. In the OnStart you could do something like this :

              protected override void OnStart(string\[\] args)
              {
                  //a handle for the Elapsed event 
                  Alarm.Elapsed += new ElapsedEventHandler(OnElapsedTime);
                  //set the interval between 2 consecutive Elapsed events
                  Alarm.Interval = SETINTERVAL; // a constant equal to 60000 ms
                  //enabling the timer
                  Alarm.Enabled = true;
              }
          

          The "alarm" object is an instance of System.Timers.Timer class. In the OnElapsedTime event you can check to see if the time has come to send the mails and call the appropiate method. As for the MailMessage class and how to use it I suggest using Google for the answer.

          I am fighting against the Universe... Reference-Rick Cook

          R 1 Reply Last reply
          0
          • R Rajeshwar Code Developer

            hello every one... plzz.. help me .. actually i want 2 send emails automatically at a particular time how can i do this ..plzz..help me...

            thanks 2 all..

            S Offline
            S Offline
            Satish Developer
            wrote on last edited by
            #5

            use system.net.mail namespace MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.techgene.net"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); G. Satish

            1 Reply Last reply
            0
            • A Albu Marius

              I have used this approach in a project of mine . I created a windows service and by default this will give you 2 event handlers : OnStart & OnStop. In the OnStart you could do something like this :

                  protected override void OnStart(string\[\] args)
                  {
                      //a handle for the Elapsed event 
                      Alarm.Elapsed += new ElapsedEventHandler(OnElapsedTime);
                      //set the interval between 2 consecutive Elapsed events
                      Alarm.Interval = SETINTERVAL; // a constant equal to 60000 ms
                      //enabling the timer
                      Alarm.Enabled = true;
                  }
              

              The "alarm" object is an instance of System.Timers.Timer class. In the OnElapsedTime event you can check to see if the time has come to send the mails and call the appropiate method. As for the MailMessage class and how to use it I suggest using Google for the answer.

              I am fighting against the Universe... Reference-Rick Cook

              R Offline
              R Offline
              Rajeshwar Code Developer
              wrote on last edited by
              #6

              plzz tell me how can i create windows service.. even i m doing on webapplication ..is it workin in web application..wht u given code 4 me..plzz tell me..brother..

              thanks 2 all..

              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