Author Topic: INI files for Datasubscriber  (Read 1535 times)

rmac

  • Newbie
  • *
  • Posts: 23
    • View Profile
INI files for Datasubscriber
« on: March 06, 2017, 01:52:35 PM »
Hello guys, I wonder if there is a way to pass some info, like email address, to the Datasubscriber through an INI file?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: INI files for Datasubscriber
« Reply #1 on: March 06, 2017, 02:16:42 PM »
Where would you want the information passed to? The DataSubscriber only reads values from the PLC and passes that to the ValueChanged event.

rmac

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: INI files for Datasubscriber
« Reply #2 on: March 06, 2017, 05:11:08 PM »
I want to be able to change the email recipients without recompiling.
I'm running a routine inside the Datasubscriber that emails one or several persons when some PLC inputs/outputs change.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: INI files for Datasubscriber
« Reply #3 on: March 06, 2017, 05:29:29 PM »
You can use the INIParser directly in your event handler:
Code: [Select]
        Dim parser As New AdvancedHMIDrivers.IniParser(".\MyData.ini")
        Dim el As String = parser.GetSetting("EmailSettings", "RecipientList")

The INI file would look like this:
Code: [Select]
[EmailSettings]
RecipientList=abc@mydomain.com, def@mydomain.com

rmac

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: INI files for Datasubscriber
« Reply #4 on: March 06, 2017, 05:37:03 PM »
Thanks a lot.
I will try and let you know.

BTW. I'm using the email routine you posted long time ago.
It works like charm with gmail. I only had to add:
                   
                    MailSendingClient.EnableSsl = True
                    MailSendingClient.Port = 587

rmac

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: INI files for Datasubscriber
« Reply #5 on: March 06, 2017, 10:32:31 PM »
I was able to send the email to all the members of the list.
I used Split(el, ",") to extract each recipient and then a For/Next to add the address to  email.To.Add(New System.Net.Mail.MailAddress())

Not much programming experience here. I guess there is a shorter way to do this. ;-)

Much appreciation for your help Archie.

dkchpe

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: INI files for Datasubscriber
« Reply #6 on: October 12, 2020, 01:26:25 PM »
Hi guys , how do i get the ini file in to the email.To.Add(New System.Net.Mail.MailAddress())?



/Christian


I was able to send the email to all the members of the list.
I used Split(el, ",") to extract each recipient and then a For/Next to add the address to  email.To.Add(New System.Net.Mail.MailAddress())

Not much programming experience here. I guess there is a shorter way to do this. ;-)

Much appreciation for your help Archie.

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: INI files for Datasubscriber
« Reply #7 on: October 12, 2020, 04:37:30 PM »
The answer appears to be in all the previous posts including the one you quoted.

dkchpe

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: INI files for Datasubscriber
« Reply #8 on: October 13, 2020, 12:33:22 AM »
yes i thought so, but im not that experienced in programming so it is not that obvious for me.
i do not understand how to make this for/next syntax and get it to work whit the email.To.Add(New System.Net.Mail.MailAddress().


 




The answer appears to be in all the previous posts including the one you quoted.

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: INI files for Datasubscriber
« Reply #9 on: October 13, 2020, 01:08:12 AM »
You should read the posts again and try to figure out why rmac started this topic, what he wanted to accomplish and under what event.

Send him a message and ask if he would be willing to share the code he used (with some fake e-mail addresses).

You still need to figure out on your end, what event should be triggering this.

dkchpe

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: INI files for Datasubscriber
« Reply #10 on: October 13, 2020, 03:37:59 AM »
Arh,  i got it now. Thanks for getting me the right direction.



You should read the posts again and try to figure out why rmac started this topic, what he wanted to accomplish and under what event.

Send him a message and ask if he would be willing to share the code he used (with some fake e-mail addresses).

You still need to figure out on your end, what event should be triggering this.