Author Topic: Email Client With Multiple Addresses  (Read 1002 times)

FuzyDragon

  • Newbie
  • *
  • Posts: 19
    • View Profile
Email Client With Multiple Addresses
« on: October 06, 2015, 08:00:51 AM »
I have been working on trying to send multiple emails using Advanced HMI on the event of an alarm bit changing. I saw Archie's post about how to send a single email through a bit change so I started with that and modified it to stream read from two .ini files. One has the email list I want to iterate through and the other has the STMP email server name we will be utilizing. The code I have runs fine but only sends an email to the first person on the list. Any ideas on how to properly iterate through to send emails to everyone on the list?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Email Client With Multiple Addresses
« Reply #1 on: October 06, 2015, 08:21:20 AM »
You should be able to just use this line multiple times with the different email address:

email.To.Add(New System.Net.Mail.MailAddress("receiver@theirdomain.com"))
email.To.Add(New System.Net.Mail.MailAddress("NextReceiver@theirdomain.com"))
email.To.Add(New System.Net.Mail.MailAddress("ThirdPerson@theirdomain.com"))

FuzyDragon

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Email Client With Multiple Addresses
« Reply #2 on: October 06, 2015, 09:05:54 AM »
OK I see what you're talking about. I was missing the New System.Net.mail.MailAddress part of the command. Thanks for the quick response