Solved

Read a signature.htm file with vb.net 2010

Posted on 2013-06-12
3
532 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 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