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. Web Development
  3. ASP.NET
  4. Email with multiple address

Email with multiple address

Scheduled Pinned Locked Moved ASP.NET
helpquestion
2 Posts 2 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.
  • S Offline
    S Offline
    Sam Heller
    wrote on last edited by
    #1

    I want to send an email to multiple people and I want to store the addresses in the web.config file. Therefore my web.config has the following and my code looks like this. Some essential has been ommited Dim message As New MailMessage() message.From = New MailAddress("site@homesolution.ltd.uk", "Homesolution Site") message.To.Add((ConfigurationManager.AppSettings("NotificationEmailAddresses")) message.Subject = "New Event Occurred" For some reason this doesn't seem to work. The email never arrives and no error appears. How do I get this to work so I can send to multiples. Thanks

    K 1 Reply Last reply
    0
    • S Sam Heller

      I want to send an email to multiple people and I want to store the addresses in the web.config file. Therefore my web.config has the following and my code looks like this. Some essential has been ommited Dim message As New MailMessage() message.From = New MailAddress("site@homesolution.ltd.uk", "Homesolution Site") message.To.Add((ConfigurationManager.AppSettings("NotificationEmailAddresses")) message.Subject = "New Event Occurred" For some reason this doesn't seem to work. The email never arrives and no error appears. How do I get this to work so I can send to multiples. Thanks

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      When I have done this before I sent a sepparate email to each person. Here is some C# code in .net 2.0 assuming you have a comma delimited list in your config file.

      MailAddress to = null;
      bool ret = false;
      if (p_to.IndexOf(",") != -1)
      {
      string[] addrs = p_to.Split(',');
      for (int i = 0; i < addrs.Length; i++)
      {
      to = new MailAddress(addrs[i]);
      ret = SendEmail(to, null, null, p_subject, p_body);
      if (!ret)
      {
      return ret;
      }
      }//for
      return ret;
      }
      else
      {
      to = new MailAddress(p_to);
      return SendEmail(to, null, null, p_subject, p_body);
      }
      <\pre>

      The SendEmail method just wraps the smtp sendmail function.

      Hope that helps.
      Ben

      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