|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 11:07 AM
Points: 602,
Visits: 671
|
|
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'
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: 2 days ago @ 8:46 AM
Points: 8,547,
Visits: 8,204
|
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 11,605,
Visits: 27,645
|
|
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 lowell SSC.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
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 11:07 AM
Points: 602,
Visits: 671
|
|
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.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 11,605,
Visits: 27,645
|
|
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, January 03, 2013 1:30 PM
Points: 1,
Visits: 3
|
|
Well, great ideas here,
One57
|
|
|
|