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. C#
  4. Automated email

Automated email

Scheduled Pinned Locked Moved C#
csharpquestion
6 Posts 4 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.
  • 1 Offline
    1 Offline
    1sabine8
    wrote on last edited by
    #1

    Hi, I need to create a C#.net console application that will send an email to some email addresses. Can anyone give me the needed code for that? Thanks in advance

    L 2 Replies Last reply
    0
    • 1 1sabine8

      Hi, I need to create a C#.net console application that will send an email to some email addresses. Can anyone give me the needed code for that? Thanks in advance

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Google for "c# console mail" and check out the first two results :-\

      I are troll :)

      1 Reply Last reply
      0
      • 1 1sabine8

        Hi, I need to create a C#.net console application that will send an email to some email addresses. Can anyone give me the needed code for that? Thanks in advance

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        private void Sendmail(string strMailMessage, string strSubject)
        {
        MailMessage myMail = new MailMessage();
        SmtpClient objSMTP = new SmtpClient("mail.domain.com");
        string strEmail = "a@domian.com,b@domain.com"; //ConfigurationSettings.AppSettings["CNotifyEmail"];
        string[] arrEMail = strEmail.Split(';');

                foreach (string strMail in arrEMail)
                {
                    myMail.To.Add(strMail);
                }
                
                myMail.From = new MailAddress("info@domain.com");
                myMail.Subject = strSubject;
                myMail.Body = strMailMessage;
                myMail.IsBodyHtml = true;
        
                try
                {
                    //obClient.Send(myMail);
                    objSMTP.Send(myMail);
                    Console.WriteLine("@@@ Notification Send....");
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("@@@ FAILED TO SEND NOTIFICATION....");
                }
        
            }
        
        S X 2 Replies Last reply
        0
        • L Lost User

          private void Sendmail(string strMailMessage, string strSubject)
          {
          MailMessage myMail = new MailMessage();
          SmtpClient objSMTP = new SmtpClient("mail.domain.com");
          string strEmail = "a@domian.com,b@domain.com"; //ConfigurationSettings.AppSettings["CNotifyEmail"];
          string[] arrEMail = strEmail.Split(';');

                  foreach (string strMail in arrEMail)
                  {
                      myMail.To.Add(strMail);
                  }
                  
                  myMail.From = new MailAddress("info@domain.com");
                  myMail.Subject = strSubject;
                  myMail.Body = strMailMessage;
                  myMail.IsBodyHtml = true;
          
                  try
                  {
                      //obClient.Send(myMail);
                      objSMTP.Send(myMail);
                      Console.WriteLine("@@@ Notification Send....");
                  }
                  catch(Exception ex)
                  {
                      Console.WriteLine(ex.ToString());
                      Console.WriteLine("@@@ FAILED TO SEND NOTIFICATION....");
                  }
          
              }
          
          S Offline
          S Offline
          Shyam K Pananghat
          wrote on last edited by
          #4

          Really good sample.. but remember you cannot catch an unsent or bounce mail info here.. :) It's just about the C# runtime error :laugh:

          Shyam.. My Blog dotnetscoups.blogspot.com

          1 Reply Last reply
          0
          • L Lost User

            private void Sendmail(string strMailMessage, string strSubject)
            {
            MailMessage myMail = new MailMessage();
            SmtpClient objSMTP = new SmtpClient("mail.domain.com");
            string strEmail = "a@domian.com,b@domain.com"; //ConfigurationSettings.AppSettings["CNotifyEmail"];
            string[] arrEMail = strEmail.Split(';');

                    foreach (string strMail in arrEMail)
                    {
                        myMail.To.Add(strMail);
                    }
                    
                    myMail.From = new MailAddress("info@domain.com");
                    myMail.Subject = strSubject;
                    myMail.Body = strMailMessage;
                    myMail.IsBodyHtml = true;
            
                    try
                    {
                        //obClient.Send(myMail);
                        objSMTP.Send(myMail);
                        Console.WriteLine("@@@ Notification Send....");
                    }
                    catch(Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        Console.WriteLine("@@@ FAILED TO SEND NOTIFICATION....");
                    }
            
                }
            
            X Offline
            X Offline
            Xmen Real
            wrote on last edited by
            #5

            Amandeep Singh Bhullar wrote:

            string strEmail = "a@domian.com,b@domain.com"; //ConfigurationSettings.AppSettings["CNotifyEmail"];
            string[] arrEMail = strEmail.Split(';');

            if I'm not wrong then you are splitting a wrong char ';'

            TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

            L 1 Reply Last reply
            0
            • X Xmen Real

              Amandeep Singh Bhullar wrote:

              string strEmail = "a@domian.com,b@domain.com"; //ConfigurationSettings.AppSettings["CNotifyEmail"];
              string[] arrEMail = strEmail.Split(';');

              if I'm not wrong then you are splitting a wrong char ';'

              TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I am sorry. But in my code the Comma seprated Email's are stored AppConfig file. Actually there is ';' than ','

              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