Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Suppress automatic Hyperlinks in outlook in HTML format Expand / Collapse
Author
Message
Posted Thursday, January 3, 2013 9:57 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 9:10 AM
Points: 607, Visits: 713
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'





  Post Attachments 
outlook.jpg (6 views, 35.61 KB)
Post #1402460
Posted Thursday, January 3, 2013 10:20 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:34 PM
Points: 13,481, Visits: 12,342
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1402471
Posted Thursday, January 3, 2013 10:56 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:30 PM
Points: 12,918, Visits: 32,089
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="http://th.fhi-berlin.mpg.de/site/img/icon_atsign.png" />')


lowell@SSC.com becomes lowellSSC.com;

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


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1402480
Posted Thursday, January 3, 2013 11:46 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 9:10 AM
Points: 607, Visits: 713
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.

Post #1402491
Posted Thursday, January 3, 2013 11:57 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:30 PM
Points: 12,918, Visits: 32,089
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1402493
Posted Thursday, January 3, 2013 12:33 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 3, 2013 1:30 PM
Points: 1, Visits: 3
Well, great ideas here,

One57
Post #1402509
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse