Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Suppress automatic Hyperlinks in outlook in HTML format


Suppress automatic Hyperlinks in outlook in HTML format

Author
Message
RJ-476420
RJ-476420
SSChasing Mays
SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)

Group: General Forum Members
Points: 616 Visits: 760
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'




Attachments
outlook.jpg (6 views, 35.00 KB)
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16580 Visits: 17024
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)
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14959 Visits: 38977
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!

RJ-476420
RJ-476420
SSChasing Mays
SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)

Group: General Forum Members
Points: 616 Visits: 760
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.
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14959 Visits: 38977
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!

abigailmatthewdavid
abigailmatthewdavid
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 3
Well, great ideas here,

One57
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search