windows Service vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarabonn
    New Member
    • Nov 2008
    • 69

    windows Service vb.net

    Hallo Everyone,

    I have created a windows service which reads the .xml data and send email once a day automatically using vb.net. works fine. Now i would like to send configure my windows service by manual changing the email id (for example get a email id from the text box in the properties or just a right click menu). Is it possible to do so ?..

    Thank you..
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    A better idea would be to store the email addresses in an XML file. Write a simple procedure to read the contents of an XML file, kindly refer to below code segment;

    Assuming this is your XML file

    Code:
      <?xml version="1.0" encoding="utf-8" standalone="yes" ?> 
    - <Table>
    - <Product>
      <Product_id>1</Product_id> 
      <Product_name>Product 1</Product_name> 
      <Product_price>1000</Product_price> 
      </Product>
    - <Product>
      <Product_id>2</Product_id> 
      <Product_name>Product 2</Product_name> 
      <Product_price>2000</Product_price> 
      </Product>
    - <Product>
      <Product_id>3</Product_id> 
      <Product_name>Product 3</Product_name> 
      <Product_price>3000</Product_price> 
      </Product>
    - <Product>
      <Product_id>4</Product_id> 
      <Product_name>Product 4</Product_name> 
      <Product_price>4000</Product_price> 
      </Product>
      </Table>
    Code to read xml nodes

    Code:
    Imports System.Xml
    Imports System.IO
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim xmldoc As New XmlDataDocument()
            Dim xmlnode As XmlNodeList
            Dim i As Integer
            Dim str As String
            Dim fs As New FileStream("products.xml", FileMode.Open, FileAccess.Read)
            xmldoc.Load(fs)
            xmlnode = xmldoc.GetElementsByTagName("Product")
            For i = 0 To xmlnode.Count - 1
                xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
                str = xmlnode(i).ChildNodes.Item(0).InnerText.Trim() & " | " & xmlnode(i).ChildNodes.Item(1).InnerText.Trim() & " | " & xmlnode(i).ChildNodes.Item(2).InnerText.Trim()
                MsgBox(str)
            Next
        End Sub
    End Class
    Kindly refer to below attached link for more details, hope it helps :)

    Basic XML Serialization in VB.NET

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Now i would like to send configure my windows service by manual changing the email id (for example get a email id from the text box in the properties or just a right click menu). Is it possible to do so ?..
      To answer your original question, yes it is possible. You just use the .Text property of the textbox.

      I would suggest that you *need* a configuration screen for your application. How else would the end user configure it for their use?

      Combine these two answers so that you have a configuration screen, that then saves the users response. Then when launching your application it loads the saved config file.

      Comment

      • sarabonn
        New Member
        • Nov 2008
        • 69

        #4
        Hallo tlhintoq,

        Thank you for your reply. Actually i have a configuration file in which the email is stored and when the service run it reads the .xml file and send the data to the same email id everytime. Now what i need to do is suppose if the user need to run the windows service and send the xml data to someother email id ?.. That's why i thought some textbox when the service is right clicked and and the value of the textbox i can change the config file value and send to that email id. any idea ?..

        Thank you..

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          That's why i thought some textbox when the service is right clicked and and the value of the textbox i can change the config file value and send to that email id.
          It sounds like you have thought out how you want it to work.
          any idea ?..
          So I don't understand what you are asking for.

          Comment

          Working...