Solved

Read a signature.htm file with vb.net 2010

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
update textboxes with Streamreader 21 47
Footer for each row on Gridview 2 21
VB.NET 2008 Publish Error 2 27
VB.net capture  result of a SQL query in variables 3 12
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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