Sub IncomingHyperlink(MyMail As MailItem) Dim strID As String Dim Body As String Dim objMail As Outlook.MailItem Dim myObject As Object Dim myDoc As Word.Document Dim mySelection As Word.Selection strID = MyMail.EntryID Set objMail = Application.Session.GetItemFromID(strID) 'Creates word application Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Add() Set objSelection = objWord.Selection 'Copies contents of email into word document objSelection.TypeText "GOOD" & objMail.HTMLBody With objSelection.Find .ClearFormatting .Text = "ASA[0-9][0-9][0-9][0-9][a-z][a-z]" .Forward = True .Wrap = wdFindAsk .MatchWildcards = True End With objSelection.Find.Execute objSelection.Hyperlinks.Add Anchor:=objSelection.Range, _ Address:="http://www.code.com/" & objSelection.Text, _ TextToDisplay:=objSelection.Text 'Copies contents to email item from word document objMail.HTMLBody = objDoc.Range(0, objDoc.Range.End) objMail.Save Set objMail = Nothing End Sub
Do while objSelection.Find.Execute() 'code to make changes in text Loop
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)