CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Replace text with Hyperlinks

    Sub ConvertToHyperlink(MyMail As MailItem)
    Dim strID As String
    Dim Body As String
    Dim objMail As Outlook.MailItem
    Dim temp As String
    Dim RegExpReplace As String
    Dim RegX As Object
    strID = MyMail.EntryID

    Set objMail = Application.Session.GetItemFromID(strID)
    Body = objMail.Body
    Body = Body + "Test"
    objMail.Body = Body

    Set RegX = CreateObject("VBScript.RegExp")
    With RegX
    .Pattern = "ASA[0-9][0-9][0-9][0-9][a-z][a-z]"
    .Global = True
    .IgnoreCase = Not MatchCase
    End With
    RegExpReplace = RegX.Replace(Body, "http://www.code.com/" + RegX.Pattern + "/ABCD")

    Set RegX = Nothing
    objMail.Body = RegExpReplace
    objMail.Save
    Set objMail = Nothing
    End Sub

    This is the code, I have so far.

    I need to have a output like this

    For example :If there is some ASA1234yy in the body of a text we should replace it with their specific embedded hyperlink in ASA1234yy.The hyperlink should have the address http://www.code.com/ASA1234yy/ABCD

    Please help me.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Replace text with Hyperlinks

    What output are you getting now?
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured