• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 813
  • Last Modified:

Hyperlinks is becoming non-clickable in RTFBody format

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,

Thanks.
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("DescoRedemption.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

Open in new window

0
deshaw
Asked:
deshaw
  • 6
  • 5
1 Solution
 
deshawAuthor Commented:
BlueDavilFan, Could you please help me here. :-)
Thanks.
0
 
David LeeCommented:
I'll see what I can do.  It may be a day or two until I get to this.
0
 
deshawAuthor Commented:
Its fine no problems.  Whenver I see your update, the hope for solution get birth. :-)
Thanks for being there.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
David LeeCommented:
How about using HTMLBody?
0
 
deshawAuthor Commented:
I cannot use HTMLBody with Redemption library. It is read only property.
Thanks.
0
 
David LeeCommented:
Yes, you can.  You just don't do it through the SafeMailItem.  Redemption allows you to work around Outlook's built-in security.  Outlook security only comes into play if your code READS the HTMLbody.  You can add to the item's HTMLBody directly without triggering security.  So instead of a line like this

    objSafeMail.RTFBody = oRE.Replace(objSafeMail.RTFBody, Link & "$1/$&")

use something like this

    objMailItem.HTMLBody = oRE.Replace(objSafeMail.HTMLBody, Link & "$1/$&")


0
 
deshawAuthor Commented:
BlueDavilFan, I am getting attached error message if I use HTMLBody.
But I could get rid of error message by declaring  "Dim objSafeMail As Redemption.SafeMailItem" statement as  "Dim objSafeMail As Object" but still the behaviour is same it is not conversting links to clickable links.
It seems Outlook doesn't recognize that http://mylink/... formate is hyper link. Is there any explicit way by which we can specify that particular string is hyper link?
Thanks.


err.JPG
0
 
David LeeCommented:
You're getting the error because you're trying to assign a value to the read-only safe mail item HTMLBody.  Please look back at my last post.  You have to assign the value to HTMLBody property of the Outlook mail item, not the safe mail item.
0
 
deshawAuthor Commented:
It has started working in Outlook 2007 fabulously.
Thanks.
0
 
deshawAuthor Commented:
thanks
0
 
David LeeCommented:
You're welcome.
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now