Solved

Read a signature.htm file with vb.net 2010

Posted on 2013-06-12
3
543 Views
Last Modified: 2013-06-13
I've never attempted this before,  any ideas on how to read the signature file from outlook using vb.net 2010. I'm wanting to read the individual line of the signature and edit them.

Any help would be greatly appreciated!

Thanks in advance.

Jim
0
Comment
Question by:transstates
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39242249
It's simply a text file (HTML) so you can open it up with a StreamReader and read it.

e.g.

Module Module1

    Sub Main()
        Using reader As New IO.StreamReader("C:\Users\kenneth\AppData\Roaming\Microsoft\Signatures\Internal.htm")
            Dim signature As String = reader.ReadToEnd()

            Console.WriteLine(signature)
        End Using
    End Sub

End Module

Open in new window


The filename will vary by how you named the signature in Outlook. Also, the path may vary based on your environment. You can adjust it according to the information here (Signatures section):

0
 

Author Comment

by:transstates
ID: 39242447
I want to be able to edit the signature if possible.  Is there a way to just read the actual signature lines and not all the others?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39242635
You'd need to parse the HTML. HTML Agility Pack would be good for this.

e.g.

Imports HtmlAgilityPack

Module Module1

    Sub Main()
        Dim htmlDoc As New HtmlDocument()

        htmlDoc.Load("C:\Users\kenneth\AppData\Roaming\Microsoft\Signatures\Internal.htm")

        For Each sigBlock As HtmlTextNode In htmlDoc.DocumentNode.SelectNodes("/html/body//p//span/text()")
            sigBlock.Text = "My new value"
        Next

        htmlDoc.Save("test.htm")

    End Sub

End Module

Open in new window


You might need to adjust the above, depending on how intricate your signatures are.

You can install HTML Agility Pack easily through NuGet, or you can download it from the link above.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question