none
How to get the links in e-mail body RRS feed

  • Question

  • Hi,

    I am new to VBA coding with Outlook 2010. Here is my requirement to get the list of links in a new e-mail body.

    Scenario:
    I have created the “Mail As Outlook.MailItem” object and now need to parse it's body text to get a text link. I am getting the mail body by Mail.Body but facing problem in getting the particular hyperlink from the whole e-mail body.

    Below is the actual example e-mail body. There are other links in the e-mail also (above and below) but I need to get this particular link.

    [Expires on: 27/Jan/2012

     Build location: Build.123.45.67.12345

     Updates : None]

    The Build location text (“Build.123.45.67.12345”) is a hyperlink and I need to get this link where it is navigating to (suppose, \\xxxx\yyyy\12345). FYI, the hyperlink text and links are dynamic that's why I want to read it runtime when mail comes in.

    Can anyone help me on that? It is urgent.


    Thanks, Avijit Chatterjee

    Thursday, April 26, 2012 7:25 AM

Answers

  • var wordDoc = (Document)inspector.WordEditor;
    foreach (Hyperlink hyperlink in wordDoc.Hyperlinks)

    Thursday, April 26, 2012 7:29 AM
  • Thank you.

    It's working fine. Here is the code snippet for further reference.

    Dim myInspector As Outlook.Inspector    Dim WordDoc As Word.Document    Dim BuildLocation As String                       Set myInspector = Mail.GetInspector    Set WordDoc = myInspector.WordEditor 

    //BuildLocation = WordDoc.Hyperlinks.Item(WordDoc.Hyperlinks.Count).Address       For Each Item In WordDoc.Hyperlinks        BuildLocation = Item.Address    Next



    Thanks, Avijit Chatterjee



    Thursday, April 26, 2012 9:26 AM

All replies

  • var wordDoc = (Document)inspector.WordEditor;
    foreach (Hyperlink hyperlink in wordDoc.Hyperlinks)

    Thursday, April 26, 2012 7:29 AM
  • Thank you.

    It's working fine. Here is the code snippet for further reference.

    Dim myInspector As Outlook.Inspector    Dim WordDoc As Word.Document    Dim BuildLocation As String                       Set myInspector = Mail.GetInspector    Set WordDoc = myInspector.WordEditor 

    //BuildLocation = WordDoc.Hyperlinks.Item(WordDoc.Hyperlinks.Count).Address       For Each Item In WordDoc.Hyperlinks        BuildLocation = Item.Address    Next



    Thanks, Avijit Chatterjee



    Thursday, April 26, 2012 9:26 AM