Suppress automatic Hyperlinks in outlook in HTML format

  • Happy New Year!

    Here is my problem that I am trying to resolve. I am sending emails using msdb.dbo.sp_send_dbmail. I have user whose user name is their email id. I send email notifications to helpdesk with the user names in the email body. I put the user names in a html table and the helpdesk people look at the mail using outlook.

    Since the user names are email the outlook automatically converts the user name to hyperlinks. I dont want the hyperlinks. I want it to display as regular text. I also want the email format to be HTML.

    Please provide any solution you may aware of to resolve the problem.

    DECLARE @EmailSubject AS NVARCHAR(255)

    ,@EmailText AS NVARCHAR(MAX)

    ,@HTMLTableData2 VARCHAR(MAX) = '<TABLE BORDER="1"><tr><th>User Name</th><th>Name</th></tr>'

    SELECT @HTMLTableData2 = @HTMLTableData2

    + '<tr>'

    + '<td>' + 'username@username.com' + '</td>'

    + '<td>' + 'FirstName' + ' ' + 'LastName' + '</td>'

    + '</tr>'

    + '<tr>'

    + '<td>' + '2username@2username.com' + '</td>'

    + '<td>' + 'FirstName2' + ' ' + '2LastName' + '</td>'

    + '</tr>'

    SELECT @HTMLTableData2 = @HTMLTableData2 + '</TABLE>'

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = N'Profile Name'

    ,@recipients = 'your email id'

    ,@blind_copy_recipients = ''

    ,@subject = 'Email Subject'

    ,@body = @HTMLTableData2

    ,@body_format = 'HTML'

  • This isn't something you can control from your code. That is how Outlook displays the text. There is a user setting in Outlook disable that feature but it is somewhat difficult to get it to work correctly and you will find that turning that feature off is a huge annoyance for everything else.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Yeah that's a feature of Outlook, not something that has anything to do with the code you generate; it finds strings with an @ in them, and converts them to links to make things easier.

    if you are ok losing the copy/pasteability, you could do what web sites do to prevent the harvesting of email addresses: replace the @ symbol with an image;

    ie

    SELECT REPLACE(userName,'@','<img src="https://www.sqlservercentral/Forums/Uploads/Images/1402480-1.png" />')

    lowell@SSC.com becomes lowellSSC.com;

    it's subtle, looks the same, but is no longer a link

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you Sean, Lowell.

    Replacing the @ with an image is a great idea but I will have to answer many questions to my testing and security teams. So, I am going to present the current code.

  • Mozilla Thunderbird, EditPlus and even Notepad++ as well as LOTS of other applciations all do the same thing when they encounter text that looks like an url or email, so it's hard to justify fiddling with the data just because someone doesn't like the behavior of that feature.

    You'll probably end up just living with the issue.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Well, great ideas here,

    One57[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply