You trying to automatically hyperlink to bugs in your bug/defects tracking application?
Easiest thing to do would be to modify the software sending the email to create the hyperlinks itself...
If you still want to do it manually, here's a quick guide I hacked together that seems to work (tested VERY lightly, but it does nominally do what it's designed to do).
Step 1: Enable the Developer tab in the Ribbon
Click Options:
![click Options](../../I/static/images/e8a549afa54d149f214b7fafcd8778e589b2241951263c7a77c3aa6b97e8d384.png)
Click Customize Ribbon, then click the Developer checkbox:
![click Customize Ribbon](../../I/static/images/66a1f776232e1e35b8e8066dc343982c3b8c3502b1af823b451366c44df08fcf.png)
Step 2: Go to VBA and put in the code
Click Visual Basic:
![Go to Visual Basic](../../I/static/images/1a421746d97b2da270362e1db8d22af91de4b72a4ee7ce06bd17e778c010e79f.png)
Double click on the ThisOutlookSession module and paste in the code as follows:
![Put in the code](../../I/static/images/ff9b8dec0b84fb522d8c6e37b6700749504869b9352adb14016154123bd5d488.png)
And now, the code:
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 = "#[0-9][0-9][0-9][0-9][0-9][0-9]"
For Each match In re.Execute(body)
body = Replace(body, match.Value, "http://example.com/bug.html?id=" & Right(match.Value, 6), 1, -1, vbTextCompare)
Next
MyMail.body = body
MyMail.Save
End Sub
Click the Save icon or press Ctrl+S
.
Step 3: Create a Custom Rule executing a Script.
Go to Manage Rules & Alerts:
![Go to Manage Rules & Alerts](../../I/static/images/69891b68b2518bfa7d7f3cc2c14c73771ea9ecc7f36ac09d66c00291afc36a94.png)
Click New Rule...:
![Click New Rule...](../../I/static/images/d40936592878abe1a9f3ba74e12ba29fa6450e516fd77987fdda38160aaad197.png)
Click "Apply rule on messages I receive", then click Next:
![Apply rule on messages I receive](../../I/static/images/d550f12dd03bc1aab3108360a5761beb05da0052d7a29ca86a8850dc46530fe5.png)
If you want to only run the rule on certain messages, you can select from any of the conditions here. Don't worry about filtering on messages containing "#123456" in the body; we do that in the code. So just filter on, for example, "From:" or the Subject, if you want. This is optional.
![Select conditions](../../I/static/images/22662dbd966e5791e2ec5e5bd5a471b7d16b17673ee203f2bee87f1ab2d52d63.png)
Choose "Run a script". Click on the text that says "a script" in blue underline in the bottom box.
![Run a script action](../../I/static/images/ed45e8d3fa301b43dddf24f891d78471478268d5d192880812a38ac7b577545b.png)
Pick the script we just created, whose name will probably be cut off due to the small dialog, but that's OK.
![Pick your script](../../I/static/images/d1e9c84300aaa617f5ec89d4f378040f5513838696c963be309d6d9160c78097.png)
At this point, you can just click "Next" and "Finish" at the bottom repeatedly until the dialogs go away; you should be done.
Now try and compose an email to yourself (or receive an email from the sender or subject line you're expecting, if you specified a custom condition) and insert a number like:
#123456
into the body, and send it.
When you get the mail message, it should have it as a URL to http://example.com/bug.html?id=123456
(where "123456" is replaced with the 6 numbers you chose).
You can customize the script code to point to a different URL by modifying the URL string within the code. You can also do more exotic things with it to either keep or remove the number, or various other things.
This answer took my entire lunch hour, so if you think it was worthwhile, please remember to vote up... Let me know in the comments if you have any difficulties or questions.
Very Helpful StackOverflow question, which at least gave me a feasibility approach for implementing this: Append Subject Header in Outlook (VBA)
if "run a script" isnt there for newer versions you can put this in regedit HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Security DWORD: EnableUnsafeClientMailRules Value: 1 – daniel – 2017-09-28T14:08:22.673
hey this is great. i spent my lunch hour implementing it. didn't seem to work in the subject field, so I'll keep playing. there are also several instances (variations) of that ID number, I'm going to adjust this to account for spacing, different characters, etc. finally I'm going to try and leave the original number text and have that mask the URL for the hyperlink. thanks again! – ikathegreat – 2012-08-20T19:48:31.467
"Didn't seem to work in the subject field" --> You mean your number is in the subject field? I assumed it was in the body. I don't think there's a way to create a hyperlink in the subject field. But you can look at the properties of
– allquixotic – 2012-08-20T20:33:29.650MailItem
(in the Outlook Automation Object Model) to try and finagle something. Lastly: using the number as hyperlink display text with the link "behind" the hyperlink is much trickier; check this for details.1Also, if you're adept at VBA programming and you want to really customize this down to exactly what you need, you may want to ask a question on StackOverflow if it's purely about programming the VBA macro to recognize and/or process the message the way you want it. – allquixotic – 2012-08-20T20:36:29.837