We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Sending Emails in asp.net, bringing up locate link browser with hyperlinks

skrombeen
skrombeen asked
on
Medium Priority
686 Views
Last Modified: 2008-02-01
Hi

I sending an email via .net, I've tried using the system.web.mail aswell as jmail's .net email sender...
and im having no luck with either of them, this is the problem:
all hyperlinks that are added to the email make the "locate link browser" pop up...
BUT...
this only happens in dot net asp.net (vb.net) and not in "classic" asp, with exactly the same body in both of them...

Here is the code snippet for the default .net msg component:
        vsBody = Replace(Replace(FreeTextBox1.Text, "#DearName#", vsContactPerson), "#RFICode#", vsUserRFICode)

        MMsgUser.From = IIf(IsDBNull(ds.Tables(0).Rows(0)("Email")), "support@coName.co.za", ds.Tables(0).Rows(0)("Email"))
        MMsgUser.BodyEncoding = System.Text.Encoding.Unicode
        MMsgUser.Subject = ds.Tables(0).Rows(0)("FullName") & " RFI"
        MMsgUser.Priority = MailPriority.High
        MMsgUser.Body = vsBody
        MMsgUser.Cc = "support@coName.co.za"
        MMsgUser.Bcc = "shaun@coName.co.za"
        MMsgUser.To = vsEmailAdd
        MMsgUser.BodyFormat = MailFormat.Html
here is the code snippet for the jmail .net email component:
         Dim mysmtp As Dimac.JMail.Smtp
       message.From.Email = IIf(IsDBNull(ds.Tables(0).Rows(0)("Email")), "support@coName.co.za", ds.Tables(0).Rows(0)("Email"))
        message.To.Add(vsEmailAdd, "")
        message.Subject = ds.Tables(0).Rows(0)("FullName") & " RFI"
        message.BodyHtml = vsBody
        message.Charset = System.Text.Encoding.Default
        mysmtp.Send(message, Configuration.ConfigurationSettings.AppSettings("SMTPServer"), 25, GetDomain(vsEmailAdd))

Comment
Watch Question

Your problem is very easy :)

There are two kind of e-mails: HTML and Text. In HTML hyperlinks work and in Text not.

You are using this in ASP:
MMsgUser.Body = vsBody // Text based e-mail

while in ASP.NET you are using:
message.BodyHtml = vsBody // Html based e-mail

I think ASP has a overload for Html also, if not, just add <html><head> etc.. tags around it and it will most likely work.

Author

Commented:
Hi Jorn

Thank you for taking the time to answer my question!

I have added the <html><head><body> tags to the beginning and the end of the html text that is sent on the email and it is still bringing up the "locate link browser" when a hyperlink is clicked within the body of the email...

Please see the "view source" on the email:
<html><head><title>RFI</title></head><body><FONT face=tahoma>Good Day Shaun<BR><BR>We at SAICA are currently updating our database of service providers.<BR><BR>To this end, we kindly request that you log on to the following website and register your company with all necessary details. This request should be completed within two days. <BR>The following steps outline the procedure to follow.<BR><BR>Please click here&gt; <A href="/defaultMentor.asp?MentorID=31">www.b1sa.co.za/defaultMentor.asp?MentorID=31</A><BR><BR>1) Click the <B><I>Register</I></B> button<BR>2) Insert your RFI Code at the top of the registration page. Your RFI code is 123123123<BR>3) Complete the first page and proceed to page 2<BR>4) Type a keyword for your business activities and click <B><I>Search SIC</B></I><BR>5) Select your business activity<BR>6) Click <B><I>Submit</B></I><BR><BR>Thank You,<BR>SAICA </FONT></body></html><BR>
-------------------

Do you see the <A href="/defaultmentor.asp">, this should be <A href="http://www.b1sa.co.za/defaultmentor.asp?MentorID=31">

???
>> Do you see the <A href="/defaultmentor.asp">, this should be <A href="http://www.b1sa.co.za/defaultmentor.asp?MentorID=31">

You are correct. Needs to be the full URL.

Author

Commented:
yes I know it needs to be that...
and it is coded that way

this is the raw code:
<html><head><title>RFI</title></head><body><font face="tahoma">Good Day #DearName#<br><br>
We at SAICA are currently updating our database of service providers.<br><br>
To this end, we kindly request that you log on to the following website and register your company with all necessary details.
This request should be completed within two days. <br>

The following steps outline the procedure to follow.<br><br>
Please click here> <a href="http://www.b1sa.co.za/defaultMentor.asp?MentorID=31">www.b1sa.co.za/defaultMentor.asp?MentorID=31</a><br><br>
1) Click the <B><i>Register</i></b> button<br>
2) Insert your RFI Code at the top of the registration page. Your RFI code is #RFICode#<br>
3) Complete the first page and proceed to page 2<br>
4) Type a keyword for your business activities and click <B><i>Search SIC</B></i><br>
5) Select your business activity<br>
6) Click <B><i>Submit</B></i><br><br>
Thank You,<br>
SAICA
</body></font></html>
--------
but when i receive the email it has removed the first part of the href...

Author

Commented:
Hello? any answer?

this question is nearly 4 days old now...

I really really need the help on this...
We have weekend also!

I can't figure out why it would remove the "http://" part, have you tried opening the e-mail in another client?

Commented:
How does the vsBody look before you add it to the MMsgUser.Body.
Look at it in Debug.
Do you have the full URL there or is it already replaced with ="/defaultMentor.asp?MentorID=31

Author

Commented:
Hi

sorry about my earlier response...my client is putting emense pressure on me to sort this out...

the vsbody in debug mode includes the full path (i.e http://www.b1sa.co.za/defaultmentor.asp?MentorID=31)

if exactly the same code runs in "classic" asp, it works perfectly...

tx
Shaun
Have you tried opening the e-mail in another client and what was it's result?
It's been a long time since I've tried sending e-mail from a web app. However, I do vaguely remember something about ASP.NET doing weird things with encoding to and from HTML.  This may be part of your issue.

What version of .NET are you using?
Top Expert 2004

Commented:
Does jmail support any type of debugging where you can get the actual SMTP messages being sent back and forth? or does your email client support viewing the actual mime message? Just trying to figure out if its the client doing it or something odd inside of the SMTP client.

also I have written an open source smtp client that you could try (and it does allow you to look at actual SMTP messages) http://sourceforge.net/projects/no-cdo

Cheers,

Greg

Author

Commented:
Hi Guys!

thanks for all your responses!

Im using .net version 1

I havn't seen any support on jmail for viewing the actual smtp messages as its the free version, so perhaps they have removed that feature from it...

Do you think it could be the version of .net? as i've been thinking about this, and if i run the project on my local pc it seems to work fine, but when i copy it to the live server this seems to be happening...
Top Expert 2004

Commented:
I don't see how the framework version could be affecting this as you are not using the framework to handle the email sending. I am unsure whether (if) jmail actually uses the underlying framework (or CDO) to send the email but my thought would be that it does not.



You may want ot make sure that both the server and your machine have the same service packs running for the .NET framework. I'm not sure if there are any SP for 1.0, but there is a SP for 1.1 (which is probably the version you're running).

Other than with service packs, both your machines will be running the same version, since the framework incorporates system.web -- and the only framework changes are made via service packs.

Commented:
.NET version 1 or version 1.1?

Also debug mode sometimes fills in things that are not actually there

Where is the code that actually creates the vsBody?  Can show tht portion of code so we can be sure it is being added to the message properly?
Greg,

He's tried both jmail and system.web.mail -- I'm sure the latter uses the framework :)

J
Top Expert 2004

Commented:
yes but since the former probably uses it in a very limited way ... my guess would be it is not the framework.

 vsBody = Replace(Replace(FreeTextBox1.Text, "#DearName#", vsContactPerson), "#RFICode#", vsUserRFICode)

You said that VsBody contains the full URL? Can you post the full contents of vsBody?

Author

Commented:
Hi

here is the contents of the vsBody:
***************************************************
<html><head><title>RFI</title></head><body><font face="tahoma">Good Day MrX<br><br>
We at SAICA are currently updating our database of service providers.<br><br>
To this end, we kindly request that you log on to the following website and register your company with all necessary details.
This request should be completed within two days. <br>

The following steps outline the procedure to follow.<br><br>
Please click here> <a href="http://www.b1sa.co.za/defaultMentor.asp?MentorID=31">www.b1sa.co.za/defaultMentor.asp?MentorID=31</a><br><br>
1) Click the <B><i>Register</i></b> button<br>
2) Insert your RFI Code at the top of the registration page. Your RFI code is 1096SIACA2121<br>
3) Complete the first page and proceed to page 2<br>
4) Type a keyword for your business activities and click <B><i>Search SIC</B></i><br>
5) Select your business activity<br>
6) Click <B><i>Submit</B></i><br><br>
Thank You,<br>
SAICA
</body></font></html>
***************************************************

yes I have tried both methods (jmail & .net), do you think the ## values are causing the problem? The actual text for the hyperlink is exactly as is the vsBody variable...

Dazed & Confused
Shaun
Top Expert 2004

Commented:
Does your email client support viewing the actual mime message?

Author

Commented:
Hi

Im using ms outlook 2003, I can have a look and see if it does support Mime messages, what should i look for in the mime message?
Please keep in mind, these emails get send to approx 5000-10000 email addresses at a time so i cant guarantee what each reciepient will have on their pc to read the messages!

tx
Shaun
Top Expert 2004

Commented:
I am trying to see if its the client re-writing the url ... or if it is coming accross that way in the MIME message.

Cheers,

Greg

Author

Commented:
oh okay!

I've never worked on a mime message...do you know how i can check this?

tx
Top Expert 2004

Commented:
dont know outlook 2003 that well but http://www.outlook-tips.net/howto/view_source.htm .. this only works for "internet" emails (doesn't work from exchange connection) ... and the registry value must be set before you get the email.

Author

Commented:
Hi Greg

here is the source code after i made the above registry change...

***********************************************
<html><head><title>RFI</title></head><body><FONT face=tahoma>Good Day Shaun<BR><BR>We at SAICA are currently updating our database of service providers.<BR><BR>To this end, we kindly request that you log on to the following website and register your company with all necessary details. This request should be completed within two days. <BR>The following steps outline the procedure to follow.<BR><BR>Please click here&gt; <A href="/defaultMentor.asp?MentorID=31">www.b1sa.co.za/defaultMentor.asp?MentorID=31</A><BR><BR>1) Click the <B><I>Register</I></B> button<BR>2) Insert your RFI Code at the top of the registration page. Your RFI code is 123123123<BR>3) Complete the first page and proceed to page 2<BR>4) Type a keyword for your business activities and click <B><I>Search SIC</B></I><BR>5) Select your business activity<BR>6) Click <B><I>Submit</B></I><BR><BR>Thank You,<BR>SAICA </FONT></body></html><BR>

<P><FONT SIZE=2>--<BR>
No virus found in this incoming message.<BR>
Checked by AVG Free Edition.<BR>
Version: 7.1.385 / Virus Database: 268.3.4/299 - Release Date: 2006/03/31<BR>
</FONT> </P>

<P><FONT SIZE=2 FACE="Arial"> </FONT> </P>
*******************************************************

Commented:
Can you try sending a test message to a non-Outlook account that does a better job of showing actual source?

Author

Commented:
mrichmon: I have forwarded a copy of the email to your email address...

thanks
Top Expert 2004

Commented:
skrom if its quicker for you to test I can show you how to send this through my email library (which I know for a fact does not mangle addresses in any way :)) or you can also send one to this name at this website.com

Author

Commented:
I've just checked with the company that is hosting this website as its on a shared server...
and they have just told me that .net frameword 1.4.xxxx is installed on the server, I have look at microsoft.com and I dont see anything like that their...

I have 1.1.4 & 1.1.0 installed on my notebook...
do you think this could be causing the problem?
.NET 1.4 does not exist, most likely they have .NET 1.1.4322 installed like you have. But I doubt it's a framework problem. I think it's a implementation problem from the classes you are using.

I suggest you give gregoryyoung's library a try. It might be obsolete, because .NET has a standard library which can do it (At least should be able to do it), but since you are getting pushed by your clients to quickly solve the problem. I do not see a reason why not to give it a try if it takes too long to fix it with .NET itself.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks for the advice Existenz2...

Gregory, would it be possible for me to use your email library?

tx
<REMOVED EMAIL, GREG>

Top Expert 2004
Commented:
http://sourceforge.net/projects/no-cdo ...

You can either use the System.Web.Mail objects with it or it has its own objects that offer additional functionality.

I believe there is a small sample with it, if you need to turn on debugging I can show you how to do that (but you have to by-pass the happy facade provided and use the objects directly)

Cheers,

Greg
Commented:
Well I was going to post the source of the message you sent so that all could see, but the message you sent was forwarded (with a HUGE attachement by the way), that already had the address filled in.  Therefore since it was a forward of a forward (there was a second message below the first forward, I couldn't tell what it originally was since it had already been manipulated by your email client.  A valid test would be do generate the message directly to another email - not forward through Outlook.

Also can you post the code that adds the web address to the vsBody variable?

Author

Commented:
Hi

The code that adds the url to the vsBody variable comes from sql and looks like this:
*******************************************************
<font face="tahoma">Good Day #DearName#<br><br>
We at SAICA are currently updating our database of service providers.<br><br>
To this end, we kindly request that you log on to the following website and register your company with all necessary details.
This request should be completed within two days. <br>

The following steps outline the procedure to follow.<br><br>
Please click here> <a href="http://www.b1sa.co.za/defaultMentor.asp?MentorID=31">www.b1sa.co.za/defaultMentor.asp?MentorID=31</a><br><br>
1) Click the <B><i>Register</i></b> button<br>
2) Insert your RFI Code at the top of the registration page. Your RFI code is #RFICode#<br>
3) Complete the first page and proceed to page 2<br>
4) Type a keyword for your business activities and click <B><i>Search SIC</B></i><br>
5) Select your business activity<br>
6) Click <B><i>Submit</B></i><br><br>
Thank You,<br>
SAICA
</font>
*************************************************
its stored as a varchar...

tx

Commented:
There has to be some line of code not in SQL that acctually adds the body to the variable.  Even if that code is reading from the database.  And some code that is replacing the #DearName# and other fields.

Author

Commented:
this was on the first post:
vsBody = Replace(Replace(FreeTextBox1.Text, "#DearName#", vsContactPerson), "#RFICode#", vsUserRFICode)

the freetextbox1.text = the value obtained from the database...

Commented:
Okay.  Missed that - sorry.

Author

Commented:
Greg, I have tried your ExpertsExchange.Utilities.Networking.Smtp

and unfortunetly the problem is still happening...

Author

Commented:
Hi guys

thank you all for your help!
I've managed to solve the problem, the Freetextbox control (www.freetextbox.com) had a default value which was hidden and it removes the server name from any url...

tisk tisk...anyways! thanks for all your help!

cheers
Shaun
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.