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..

minus.gif
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.
Similar threads
Thread starter Title Forum Replies Date
O Hyperlink formatting lost after replacement in outlook Using Outlook 5
V Embedding hyperlink into Word document Using Outlook 2
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 Using Outlook 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
P Hyperlink to Access record/Form Outlook VBA and Custom Forms 2
M auto click hyperlink?! Outlook VBA and Custom Forms 1
M Auto click a hyperlink Outlook VBA and Custom Forms 2
R Inserting a hyperlink in the bod of an outlook appt. Outlook VBA and Custom Forms 13
K Add Hyperlink in Email Body by VBA Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
K Outlook tasks formatting Using Outlook 4
E Conditional formatting - when current account <> received account ? Using Outlook 3
V Outlook Forms: Formatting a Label with 2 different styles Outlook VBA and Custom Forms 1
P BCM conditional formatting BCM (Business Contact Manager) 5
S Conditional Formatting for messages in a Conversation thread Using Outlook 1
S Conditional Formatting in calendar part of To-Do Bar Using Outlook 1
S Conditional formatting problem with "is not empty" and categories Using Outlook 2
N How to remove signature formatting from Text in Word (accidentally taken from Outlook) Using Outlook 0
K Conditional Formatting based on Department of person received from? Outlook VBA and Custom Forms 4
M Using conditional formatting on a shared calendar with categories Using Outlook 6
L Email to task without changin formatting Outlook VBA and Custom Forms 16
K Paste from Windows Clipboard then change font without losing formatting Outlook VBA and Custom Forms 1
C Change default colors for conditional formatting Using Outlook 2
Diane Poremsky Use Word Macro to Apply Formatting to Email Using Outlook 0
makinmyway How Prevent Re-Formatting of Contact Notes Field When Syncing Using Outlook 10
G outlook 13 copy & paste without losing formatting Using Outlook 1

Similar threads

Top