Hyperlinks is becoming non-clickable in RTFBody format

Status
Not open for further replies.
C

cGFyZXNo

Hi,

I have written one add-in which replaces [a-zA-z]#[0-9] or

[a-zA-z]#[0-9]#[0-9] with the hyperlinks. It is working fine(attached portion

of code). I found the two problems.

1. The hyperlink (in format of "http://mylink/Q/") is getting converted

into clickable link if I use objSafeMail.Body instead of objSafeMail.RTFBody

in my code but usage of objSafeMail.Body converts mail format to plain text.

2. If I use objSafeMail.RTFBody then hyperlink is becoming non-clickable.

Could any one suggest me if in Option#1 (while using objSafeMail.Body) it is

possible to persist email format as it is OR in Option#2 is it possible to

make replaced hyperlink to clickable,

Code:

Private Sub objMailItem_Send(Cancel As Boolean)

Const Link = "http://mylink/Q/"

Const REQUEST_PATTERN = "([a-zA-Z]+)(\#[0-9]+){1,2}(?!\#)\b"

Set oRE = CreateObject("VBScript.Regexp")

With oRE

> IgnoreCase = True

> Global = True

> MultiLine = True

> Pattern = REQUEST_PATTERN

End With

objMailItem.BodyFormat = olFormatHTML

objMailItem.Save

Dim objSafeMail As Redemption.SafeMailItem

Set objSafeMail = CreateObject("Redemption.SafeMailItem")

objSafeMail.Item = objMailItem

Set oMatches = oRE.Execute(objSafeMail.Body)

objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody, Link &

"$1/$&")

objSafeMail.Save

For Each omatch In oMatches

objSafeMail.RTFBody = Replace(objSafeMail.RTFBody, "/" &

omatch.SubMatches(0) & "#", "/")

objSafeMail.Save

Next

End Sub

Thanks.
 
D

Dmitry Streblechenko

And if you look at the RTF body, what exactly do you see?

Dmitry Streblechenko (MVP)

-

"paresh" <paresh> wrote in message

news:EDDCAFD1-AC4C-47FC-802C-3DCCB0F2660C@microsoft.com...
> Hi,

> I have written one add-in which replaces [a-zA-z]#[0-9] or
> [a-zA-z]#[0-9]#[0-9] with the hyperlinks. It is working fine(attached
> portion
> of code). I found the two problems.

> 1. The hyperlink (in format of "http://mylink/Q/") is getting converted
> into clickable link if I use objSafeMail.Body instead of
> objSafeMail.RTFBody
> in my code but usage of objSafeMail.Body converts mail format to plain
> text.

> 2. If I use objSafeMail.RTFBody then hyperlink is becoming
> non-clickable.

> Could any one suggest me if in Option#1 (while using objSafeMail.Body) it
> is
> possible to persist email format as it is OR in Option#2 is it possible to
> make replaced hyperlink to clickable,

> Code:

> Private Sub objMailItem_Send(Cancel As Boolean)
> Const Link = "http://mylink/Q/"
> Const REQUEST_PATTERN = "([a-zA-Z]+)(\#[0-9]+){1,2}(?!\#)\b"
> Set oRE = CreateObject("VBScript.Regexp")
> With oRE
> .IgnoreCase = True
> .Global = True
> .MultiLine = True
> .Pattern = REQUEST_PATTERN
> End With
> objMailItem.BodyFormat = olFormatHTML
> objMailItem.Save
> Dim objSafeMail As Redemption.SafeMailItem
> Set objSafeMail = CreateObject("Redemption.SafeMailItem")
> objSafeMail.Item = objMailItem
> Set oMatches = oRE.Execute(objSafeMail.Body)
> objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody, Link &
> "$1/$&")
> objSafeMail.Save

> For Each omatch In oMatches
> objSafeMail.RTFBody = Replace(objSafeMail.RTFBody, "/" &
> omatch.SubMatches(0) & "#", "/")
> objSafeMail.Save
> Next
> End Sub

> Thanks.
 
C

cGFyZXNo

Dmitry, I could see the complete expected contents. Suppose my email RTFbody

contains "This is a test#123." Then my Add-in converts it to "This is

http://mylink/Q/test/123." but the hyperlink is staying non-clickable. If I

do the same thing using email body (not RTFBody) then link get converted into

clickable link but format is getting changed to plain text. :-(

Thanks,

Paresh

"Dmitry Streblechenko" wrote:


> And if you look at the RTF body, what exactly do you see?

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "paresh" <paresh> wrote in message
> news:EDDCAFD1-AC4C-47FC-802C-3DCCB0F2660C@microsoft.com...
> > Hi,
> > I have written one add-in which replaces [a-zA-z]#[0-9] or
> > [a-zA-z]#[0-9]#[0-9] with the hyperlinks. It is working fine(attached
> > portion
> > of code). I found the two problems.
> > 1. The hyperlink (in format of "http://mylink/Q/") is getting converted
> > into clickable link if I use objSafeMail.Body instead of
> > objSafeMail.RTFBody
> > in my code but usage of objSafeMail.Body converts mail format to plain
> > text.
> > 2. If I use objSafeMail.RTFBody then hyperlink is becoming
> > non-clickable.
> > Could any one suggest me if in Option#1 (while using objSafeMail.Body) it
> > is
> > possible to persist email format as it is OR in Option#2 is it possible to
> > make replaced hyperlink to clickable,
> > Code:
> > Private Sub objMailItem_Send(Cancel As Boolean)
> > Const Link = "http://mylink/Q/"
> > Const REQUEST_PATTERN = "([a-zA-Z]+)(\#[0-9]+){1,2}(?!\#)\b"
> > Set oRE = CreateObject("VBScript.Regexp")
> > With oRE
> > .IgnoreCase = True
> > .Global = True
> > .MultiLine = True
> > .Pattern = REQUEST_PATTERN
> > End With
> > objMailItem.BodyFormat = olFormatHTML
> > objMailItem.Save
> > Dim objSafeMail As Redemption.SafeMailItem
> > Set objSafeMail = CreateObject("Redemption.SafeMailItem")
> > objSafeMail.Item = objMailItem
> > Set oMatches = oRE.Execute(objSafeMail.Body)
> > objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody, Link &
> > "$1/$&")
> > objSafeMail.Save
> > For Each omatch In oMatches
> > objSafeMail.RTFBody = Replace(objSafeMail.RTFBody, "/" &
> > omatch.SubMatches(0) & "#", "/")
> > objSafeMail.Save
> > Next
> > End Sub
> > Thanks.


>
 
D

Dmitry Streblechenko

Why do you expect it to become a hyperlink? You need to explicitly use the

appropriate RTF keywords to mark soem string as a hyperlink.

Dmitry Streblechenko (MVP)

-

"paresh" <paresh> wrote in message

news:7104D687-3D00-4875-90F1-7EB591484F68@microsoft.com...
> Dmitry, I could see the complete expected contents. Suppose my email
> RTFbody
> contains "This is a test#123." Then my Add-in converts it to "This is
> http://mylink/Q/test/123." but the hyperlink is staying non-clickable. If
> I
> do the same thing using email body (not RTFBody) then link get converted
> into
> clickable link but format is getting changed to plain text. :-(

> Thanks,
> Paresh

> "Dmitry Streblechenko" wrote:
>
> > And if you look at the RTF body, what exactly do you see?
>

>> > > Dmitry Streblechenko (MVP)
> >

> >

> >

> > -
> > "paresh" <paresh> wrote in message
> > news:EDDCAFD1-AC4C-47FC-802C-3DCCB0F2660C@microsoft.com...
> > > Hi,
> >> > I have written one add-in which replaces [a-zA-z]#[0-9] or
> > > [a-zA-z]#[0-9]#[0-9] with the hyperlinks. It is working fine(attached
> > > portion
> > > of code). I found the two problems.
> >> > 1. The hyperlink (in format of "http://mylink/Q/") is getting
> > > converted
> > > into clickable link if I use objSafeMail.Body instead of
> > > objSafeMail.RTFBody
> > > in my code but usage of objSafeMail.Body converts mail format to plain
> > > text.
> >> > 2. If I use objSafeMail.RTFBody then hyperlink is becoming
> > > non-clickable.
> >> > Could any one suggest me if in Option#1 (while using objSafeMail.Body)
> > > it
> > > is
> > > possible to persist email format as it is OR in Option#2 is it possible
> > > to
> > > make replaced hyperlink to clickable,
> >> > Code:
> >> > Private Sub objMailItem_Send(Cancel As Boolean)
> > > Const Link = "http://mylink/Q/"
> > > Const REQUEST_PATTERN = "([a-zA-Z]+)(\#[0-9]+){1,2}(?!\#)\b"
> > > Set oRE = CreateObject("VBScript.Regexp")
> > > With oRE
> > > .IgnoreCase = True
> > > .Global = True
> > > .MultiLine = True
> > > .Pattern = REQUEST_PATTERN
> > > End With
> > > objMailItem.BodyFormat = olFormatHTML
> > > objMailItem.Save
> > > Dim objSafeMail As Redemption.SafeMailItem
> > > Set objSafeMail = CreateObject("Redemption.SafeMailItem")
> > > objSafeMail.Item = objMailItem
> > > Set oMatches = oRE.Execute(objSafeMail.Body)
> > > objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody, Link
> > > &
> > > "$1/$&")
> > > objSafeMail.Save
> >> > For Each omatch In oMatches
> > > objSafeMail.RTFBody = Replace(objSafeMail.RTFBody, "/" &
> > > omatch.SubMatches(0) & "#", "/")
> > > objSafeMail.Save
> > > Next
> > > End Sub
> >> > Thanks.

>

>
>>
 
C

cGFyZXNo

I thought it is link and as it getting coverted to clickable link while using

> .Body so it should with .RTFBody as well. :)

Could you tell me what are the RT Keywords and how could I use it to make it

clickable hyper link. Example would be much helpful.

Thanks,

Paresh

"Dmitry Streblechenko" wrote:


> Why do you expect it to become a hyperlink? You need to explicitly use the
> appropriate RTF keywords to mark soem string as a hyperlink.

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "paresh" <paresh> wrote in message
> news:7104D687-3D00-4875-90F1-7EB591484F68@microsoft.com...
> > Dmitry, I could see the complete expected contents. Suppose my email
> > RTFbody
> > contains "This is a test#123." Then my Add-in converts it to "This is
> > http://mylink/Q/test/123." but the hyperlink is staying non-clickable. If
> > I
> > do the same thing using email body (not RTFBody) then link get converted
> > into
> > clickable link but format is getting changed to plain text. :-(
> > Thanks,
> > Paresh
> > "Dmitry Streblechenko" wrote:
> >
> >> And if you look at the RTF body, what exactly do you see?
> >
> >> > >> Dmitry Streblechenko (MVP)
> >>

> >>

> >>

> >> -
> >> "paresh" <paresh> wrote in message
> >> news:EDDCAFD1-AC4C-47FC-802C-3DCCB0F2660C@microsoft.com...
> >> > Hi,
> >> >> > I have written one add-in which replaces [a-zA-z]#[0-9] or
> >> > [a-zA-z]#[0-9]#[0-9] with the hyperlinks. It is working fine(attached
> >> > portion
> >> > of code). I found the two problems.
> >> >> > 1. The hyperlink (in format of "http://mylink/Q/") is getting
> >> > converted
> >> > into clickable link if I use objSafeMail.Body instead of
> >> > objSafeMail.RTFBody
> >> > in my code but usage of objSafeMail.Body converts mail format to plain
> >> > text.
> >> >> > 2. If I use objSafeMail.RTFBody then hyperlink is becoming
> >> > non-clickable.
> >> >> > Could any one suggest me if in Option#1 (while using objSafeMail.Body)
> >> > it
> >> > is
> >> > possible to persist email format as it is OR in Option#2 is it possible
> >> > to
> >> > make replaced hyperlink to clickable,
> >> >> > Code:
> >> >> > Private Sub objMailItem_Send(Cancel As Boolean)
> >> > Const Link = "http://mylink/Q/"
> >> > Const REQUEST_PATTERN = "([a-zA-Z]+)(\#[0-9]+){1,2}(?!\#)\b"
> >> > Set oRE = CreateObject("VBScript.Regexp")
> >> > With oRE
> >> > .IgnoreCase = True
> >> > .Global = True
> >> > .MultiLine = True
> >> > .Pattern = REQUEST_PATTERN
> >> > End With
> >> > objMailItem.BodyFormat = olFormatHTML
> >> > objMailItem.Save
> >> > Dim objSafeMail As Redemption.SafeMailItem
> >> > Set objSafeMail = CreateObject("Redemption.SafeMailItem")
> >> > objSafeMail.Item = objMailItem
> >> > Set oMatches = oRE.Execute(objSafeMail.Body)
> >> > objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody, Link
> >> > &
> >> > "$1/$&")
> >> > objSafeMail.Save
> >> >> > For Each omatch In oMatches
> >> > objSafeMail.RTFBody = Replace(objSafeMail.RTFBody, "/" &
> >> > omatch.SubMatches(0) & "#", "/")
> >> > objSafeMail.Save
> >> > Next
> >> > End Sub
> >> >> > Thanks.
> >
> >
> >>


>
 
D

Dmitry Streblechenko

I don't remember it of the top of my head, but it shoul be easy to create a

clickable link through the OUtlook UI and then just look at the RTF data.

Dmitry Streblechenko (MVP)

-

"paresh" <paresh> wrote in message

news:3B09C293-8C18-4367-AE2C-4149FC65F3EB@microsoft.com...
> I thought it is link and as it getting coverted to clickable link while
> using
> .Body so it should with .RTFBody as well. :)

> Could you tell me what are the RT Keywords and how could I use it to make
> it
> clickable hyper link. Example would be much helpful.

> Thanks,
> Paresh

> "Dmitry Streblechenko" wrote:
>
> > Why do you expect it to become a hyperlink? You need to explicitly use
> > the
> > appropriate RTF keywords to mark soem string as a hyperlink.
>

>> > > Dmitry Streblechenko (MVP)
> >

> >

> >

> > -
> > "paresh" <paresh> wrote in message
> > news:7104D687-3D00-4875-90F1-7EB591484F68@microsoft.com...
> > > Dmitry, I could see the complete expected contents. Suppose my email
> > > RTFbody
> > > contains "This is a test#123." Then my Add-in converts it to "This is
> > > http://mylink/Q/test/123." but the hyperlink is staying non-clickable.
> > > If
> > > I
> > > do the same thing using email body (not RTFBody) then link get
> > > converted
> > > into
> > > clickable link but format is getting changed to plain text. :-(
> >> > Thanks,
> > > Paresh
> >> > "Dmitry Streblechenko" wrote:
> >> >> And if you look at the RTF body, what exactly do you see?
> > >
>> >> > > >> Dmitry Streblechenko (MVP)
> > >>

> > >>

> > >>

> > >> -
> > >> "paresh" <paresh> wrote in message
> > >> news:EDDCAFD1-AC4C-47FC-802C-3DCCB0F2660C@microsoft.com...
> > >> > Hi,
> > >>> >> > I have written one add-in which replaces [a-zA-z]#[0-9] or
> > >> > [a-zA-z]#[0-9]#[0-9] with the hyperlinks. It is working
> > >> > fine(attached
> > >> > portion
> > >> > of code). I found the two problems.
> > >>> >> > 1. The hyperlink (in format of "http://mylink/Q/") is getting
> > >> > converted
> > >> > into clickable link if I use objSafeMail.Body instead of
> > >> > objSafeMail.RTFBody
> > >> > in my code but usage of objSafeMail.Body converts mail format to
> > >> > plain
> > >> > text.
> > >>> >> > 2. If I use objSafeMail.RTFBody then hyperlink is becoming
> > >> > non-clickable.
> > >>> >> > Could any one suggest me if in Option#1 (while using
> > >> > objSafeMail.Body)
> > >> > it
> > >> > is
> > >> > possible to persist email format as it is OR in Option#2 is it
> > >> > possible
> > >> > to
> > >> > make replaced hyperlink to clickable,
> > >>> >> > Code:
> > >>> >> > Private Sub objMailItem_Send(Cancel As Boolean)
> > >> > Const Link = "http://mylink/Q/"
> > >> > Const REQUEST_PATTERN = "([a-zA-Z]+)(\#[0-9]+){1,2}(?!\#)\b"
> > >> > Set oRE = CreateObject("VBScript.Regexp")
> > >> > With oRE
> > >> > .IgnoreCase = True
> > >> > .Global = True
> > >> > .MultiLine = True
> > >> > .Pattern = REQUEST_PATTERN
> > >> > End With
> > >> > objMailItem.BodyFormat = olFormatHTML
> > >> > objMailItem.Save
> > >> > Dim objSafeMail As Redemption.SafeMailItem
> > >> > Set objSafeMail = CreateObject("Redemption.SafeMailItem")
> > >> > objSafeMail.Item = objMailItem
> > >> > Set oMatches = oRE.Execute(objSafeMail.Body)
> > >> > objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody,
> > >> > Link
> > >> > &
> > >> > "$1/$&")
> > >> > objSafeMail.Save
> > >>> >> > For Each omatch In oMatches
> > >> > objSafeMail.RTFBody = Replace(objSafeMail.RTFBody,
> > >> > "/" &
> > >> > omatch.SubMatches(0) & "#", "/")
> > >> > objSafeMail.Save
> > >> > Next
> > >> > End Sub
> > >>> >> > Thanks.
> > >
>> >
>> >>

>

>
>>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Print email and, attachments sent in hyperlinks in the email Outlook VBA and Custom Forms 2
GregS Hyperlinks inactive Using Outlook 4
C Hyperlinks not working in Outlook Using Outlook 2
U Using VBA to creat hyperlinks in an email Outlook VBA and Custom Forms 3
B Insert Hyperlinks for attachments in Userform Outlook VBA and Custom Forms 5
H Outlook Images showing as hyperlinks Using Outlook 3
Jaegel Email Hyperlinks from one source won't open Using Outlook 4
Diane Poremsky Open All Hyperlinks in a Email Message Using Outlook 0
Sarge USMC how do I enable hyperlinks in Outlook 2013 Using Outlook 1
B Right click-drag no longer creates hyperlinks Using Outlook 2
RookieOne Hyperlinks are not working in Outlook 2013 Using Outlook 1
G Outlook mailmerge images and images hyperlinks Using Outlook 1
J Hyperlinks to batch files with parameters Using Outlook 3
L Hyperlinks Will Not Display Web Page Using Outlook 9
L Create hyperlinks to bookmarks in Outlook 2003 otf file Using Outlook 1
O Hyperlinks from Outlook 2007 Using Outlook 1
O Macro for creating hyperlinks in Outlook 2007 Using Outlook 3
N Unable to Open Hyperlinks in Outlook 2010 Using Outlook 3
A Hyperlinks to excel files Outlook Wishlist 0
P outlook 2007 - custom buttoms with hyperlinks to oft files Outlook VBA and Custom Forms 1
Q Creating hyperlinks Outlook VBA and Custom Forms 4
D Outlook Profiles becoming corrupted Using Outlook 0
H initiated by... becoming unlinked BCM (Business Contact Manager) 8
F VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
R Auto display of new email does not work on non-default account Outlook VBA and Custom Forms 0
T The non-email functions Using Outlook 8
cricket1001 Shade non-working days in calendar Using Outlook 0
O Address list - company and non-company ? Using Outlook 0
O Non-standard fonts - are they embedded? Using Outlook 2
G Auto accept meeting request for non primary account Outlook VBA and Custom Forms 1
Mark White VBScript Move sent mail to non-default folder Outlook VBA and Custom Forms 5
Mark White VBScript Move sent mail to non-default folder Outlook VBA and Custom Forms 0
V importing appointments to non-default calendar? Using Outlook 1
Diane Poremsky Working with VBA and non-default Outlook Folders Using Outlook 0
C Copy Task to Non-Microsoft PIM "Rainlendar" Using Outlook 0
Commodore Is Outlook.com EAS in Outlook 2013 "non-renamable"? Using Outlook.com accounts in Outlook 2
R Microsoft Outlook 2010 - Non Cached Mode Using Outlook 0
R Outlook Database to a non-Outlook PC Using Outlook 10
A have hundreds of non delivered emails Using Outlook 3
E Reply from non-authorised mailbox Using Outlook 7
O Calendar bookings - conflict for non-reccurent but continous booking Exchange Server Administration 1
N Delete non working emails from contacts Outlook Wishlist 1
A Outlook for smartphone with non-microsoft email address Using Outlook 1
V Outlook 2010 non working rules Using Outlook 1
J VPN interfering with the non-VPN Outlook account Using Outlook 2
S Outlook 2007 Rules randomly stopping working (non-Exchange Server) Using Outlook 6
S Automated way to move messages to a non-outlokk folder - saves as Outlook VBA and Custom Forms 1
E Pull Data From Non-Default Calendar Outlook VBA and Custom Forms 2
C Setting a non-standard default meeting length? Using Outlook 4

Similar threads

Top