I am putting together a POC for my company regarding some monitoring tools that we use. As part of my project I need to convert portions of a plaintext email sent to me into a hyperlink (I am not able to send the emails in HTML from the tool itself).
I have next to no experience with VB, but this is what I stitched together reading various other posts. I realize it is not functional at all, but I thought it might be something of a baseline for others get a better idea of what I am trying to accomplish and give feedback on. Essentially I am trying to search the email for a string, and convert it into a more concise hyperlink that points to that same string as the url.
I need some help cleaning up what I have if you have any pointers.
Option Explicit
Sub InsertHyperLink(MyMail As MailItem)
Dim body As String, re As Object, match As Variant
body = MyMail.body
Set re = CreateObject("vbscript.regexp")
re.Pattern = "^https\..*Operation>$"
For Each match In re.Execute(body)
body = Replace(body, match.Value, "<a href=""" & Right(match.Value) & """>Open Link</a>", 1, -1, vbTextCompare)
Next
MyMail.body = body
MyMail.Save
End Sub