Hyperlink formatting lost after replacement in outlook

Status
Not open for further replies.

outlookmacro

Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I have written a code which replaces the text of certain format into a hyperlink. This code is invoked by a rule during an Incoming email.

Incoming email -> copy the email to word editor -> make necessary changes -> copy from word editor to outlook mail item(replaced hyperlinks gets lost in mail item, while newly added text reamins intact)

My code is here for your refernce..

Collapse | Copy Code

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 SubAlso, this code replaces only the first occurrence of the needed text and does not replace others.
Please help solve these problems. Thank you...
I have tried out different options and still not able to get it work.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
O Hyperlink formatting lost after replacement in outlook Using Outlook 5
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
L Ignore hyperlink from being flagged as false pattern Outlook VBA and Custom Forms 3
D Custom form with html hyperlink Outlook VBA and Custom Forms 7
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
M VBA Rule for removing all body but hyperlink then forwarding Outlook VBA and Custom Forms 9
M How to view the URL for a hyperlink? Using Outlook 1
A Add Hyperlink to Task Outlook VBA and Custom Forms 11
Q Why can't I copy image with embedded hyperlink from email to Word Using Outlook 0
P URL Hyperlink not working correctly in Outlook 2003 Using Outlook 10
A Create Macro for hyperlink(email) in message body Outlook VBA and Custom Forms 9
Diane Poremsky Disable the Unsafe Hyperlink Warning when Opening Attachments New Slipstick.com Articles 0
V Using custom field data in mail body + mailto hyperlink Outlook VBA and Custom Forms 7
C Hyperlink to an Outlook search Using Outlook 1
makinmyway Recent Files Not Updating when Using Insert Hyperlink in Outlook 2013 Using Outlook 0
E Create a URL hyperlink in an Outlook custom form? Outlook VBA and Custom Forms 2
J Macro generating email using default signature and hyperlink Outlook VBA and Custom Forms 5
witzker HYPERLINK "mailto:test@test.com" in form body Using Outlook 21
Hudas Hyperlink Saved Outlook Email to MS Access Table Using Outlook 4
D Particular Facebook "Hyperlink" Issue In Office 2010 Outlook (32 bit) Using Outlook 5
S email body without "HYPERLINK" ( vba ) Using Outlook 6
M How to create a hyperlink to to an organizational form Using Outlook 5
J Hyperlink VBA Using Outlook 1
P Can't add a custom hyperlink to toolbar in OL 2010 Using Outlook 1
T Desable Hyperlink on email Using Outlook 3
G Hyperlink Using Outlook 1
T Hyperlink Issue Using Outlook 2
C Outlook 2010 hyperlink blocked in Windows 7 Home Premium Using Outlook 2
C cannot access hyperlink in Outlook 2007 Using Outlook 1
J Hyperlink error in Outlook 2010 Using Outlook 2
P hyperlink no longer woking Using Outlook 2
D Error message when clicking on hyperlink within email: 'This operation has been canceled due to restrictions in effect on this computer...' Using Outlook 1
B How do I Insert a hyperlink (to company network) in an appointment in Outlook to distribute to attendees? Using Outlook 1
P unable to use hyperlink in outlook 10 Using Outlook 1
D Cannot open Hyperlink in outlook2010 Using Outlook 3
S Outlook 2007 will not show files under the folders any longer when creating a hyperlink. No error messages Using Outlook 1
E Hyperlink Problem in Outlook Using Outlook 2
E Opening a hyperlink Using Outlook 1
C Default folder Hyperlink outlook 2007 Using Outlook 2
T I am receiving the following error message on my home computer whenever I try to open a hyperlink in Using Outlook 5
G When forwarding an email that I've received with a hyperlink, the hyperlink stops working- Outlook 2 Using Outlook 3
A When I click a hyperlink in Outlook 2007 I get a message saying action has been closed - refer to administrator.__How do I turn this off? Using Outlook 1
N Hyperlink in outlook 2003 appointment/meeting Using Outlook 1
C Need to know how to allow a hyperlink to work from and email in outlook 2010. Currently they are blocked and telling me to check with administrator. Using Outlook 3
K Inserting a hyperlink into an email will crash Outlook. Using Outlook 1
T Outlook 2007 hangs when cursor passes over a hyperlink Using Outlook 2
K Picture in email shows as hyperlink to an email address Using Outlook 1
M Shortcut Key Needed Working with Dialog Box while Inserting Hyperlink in a Contact Using Outlook 1
S hyperlink error message Using Outlook 1
Y Outlook 2007 crashes while inserting network shared path hyperlink into mail body Using Outlook 8
Similar threads


















































Top