Space in the Hyperlink in the Email body - CDOSYS

I am using CDOSYS to send an email in Classic ASP.

Here is the code:
<%
            Dim objCDO            'cdosys
            Dim EmailUrl
            Dim strBody
            Dim comment
            Dim Toaddress
            Dim CCaddress
            
            Toaddress = Trim(request.Form("toaddress"))      
            CCaddress = Trim(request.Form("ccaddress"))            
            comment = Trim(request.Form("ta_comment"))
            
            EmailUrl = "http://mysite/mycontent/default.aspx?"                              
            EmailUrl =  EmailUrl & "id=536&En=456&pr=10021023"

            Set objCDO      = Server.CreateObject("CDO.Message")
            
            objCDO.To      = Toaddress
            objCDO.Cc      = CCaddress
            objCDO.From = "admin@mysite.com"                        
            objCDO.subject ="See the Latest Content"                        
            strBody = strBody & comment & "<p>" & vbCrLf
            strBody = strBody & "Please follow the link below to see the latest content" & vbCrLf                  
            
            EmailURL = Replace(EmailURL, " " , "")            
            loc_URL2 = Trim(EmailURL)
                        
            strBody=strBody & "<a href='"& loc_URL2 &"' target='Email'>" & EmailUrl & "</a>" & "<p>"
            strBody=strBody & "Immediate response is required"
            
            objCDO.HTMLbody = "<font face='Verdana' Size 7pt;>" & strBody & "</font>"
            objCDO.Fields("urn:schemas:httpmail:importance").Value = 2
            objCDO.Fields.Update()
            objCDO.Send
            
            Response.Write "Mail sent!"
            set objCDO = nothing
%>


-- I am able to send the email.  When user clicks the url in the email body, he is getting an error. page 404 found. When we see the view source of the email body page, we found the email url as
http://mysite/mycontent/default.asp%20x?id=536&En=456&pr=10021023

But it should be --> http://mysite/mycontent/default.aspx?id=536&En=456&pr=10021023

I have used .HTMLbody format.  I have used vbCrLf before the hyperlink.  Depending on the size of the comments, the position of %20 varies in the email url string.

Can you please tell me how to pass the correct url link in the email body so that my users can access the content?
harigabbitaAsked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0
 
kevp75Commented:
not sure how much this will help,as everything looks right....try to do the URL without concatenating:

  EmailUrl = "http://mysite/mycontent/default.aspx?id=536&En=456&pr=10021023"
0
 
harigabbitaAuthor Commented:
I  have tried that one. But getting the same kind of error.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
kevp75Commented:
then i am at a loss, as I have never had an issue with an email script, all of a sudden putting in something that is not coded in
0
 
harigabbitaAuthor Commented:
Earlier we were using window2000 server. Now we have migrated to Windows 2003 Server. After the migration the problem started.  Some users are getting correct url link in their email body. But some users are getting the url link with %20. It is breaking in this scenario.
0
 
kevp75Commented:
ok....do us a quick favor:  change it to his and run the page a few times.  Make sure to check out the source code of the page...in paticular, look for a space in the URL

<%
            Dim objCDO            'cdosys
            Dim EmailUrl
            Dim strBody
            Dim comment
            Dim Toaddress
            Dim CCaddress
           
            Toaddress = Trim(request.Form("toaddress"))      
            CCaddress = Trim(request.Form("ccaddress"))            
            comment = Trim(request.Form("ta_comment"))
           
            EmailUrl = "http://mysite/mycontent/default.aspx?"                             
            EmailUrl =  EmailUrl & "id=536&En=456&pr=10021023"

           ' Set objCDO      = Server.CreateObject("CDO.Message")
           
           ' objCDO.To      = Toaddress
          '  objCDO.Cc      = CCaddress
           ' objCDO.From = "admin@mysite.com"                        
           ' objCDO.subject ="See the Latest Content"                        
            strBody = strBody & comment & "<p>" & vbCrLf
            strBody = strBody & "Please follow the link below to see the latest content" & vbCrLf                  
           
            EmailURL = Replace(EmailURL, " " , "")            
            loc_URL2 = Trim(EmailURL)
                       
            strBody=strBody & "<a href='"& loc_URL2 &"' target='Email'>" & EmailUrl & "</a>" & "<p>"
            strBody=strBody & "Immediate response is required"
            response.write("<font face='Verdana' Size 7pt;>" & strBody & "</font>")
            'objCDO.HTMLbody = "<font face='Verdana' Size 7pt;>" & strBody & "</font>"
            'objCDO.Fields("urn:schemas:httpmail:importance").Value = 2
            'objCDO.Fields.Update()
           ' objCDO.Send
           
            Response.Write "Mail sent!"
           ' set objCDO = nothing
%>
0
 
kevp75Commented:
if you do not see a space in the URL, than there is nothing (absolutely nothing) wrong with your code, and the issue is on the client's end
0
 
harigabbitaAuthor Commented:
I ran the code in win2003 server. I am getting the correct url string. I have to check with the users.  whether they are getting in the same way or not.
0
 
kevp75Commented:
ok...the issue is not with your code.  It is an issue with the users email clients
0
 
harigabbitaAuthor Commented:
Hi kevp75,

Do you think that this is related to CDOSYS settings in windows 2003 server as the same code of CDOSYS never created any problem in windows 2000 server ?
0
 
kevp75Commented:
not that I have seen, but I will search around.  Do you have another email component on the server that you may be able to try out?
0
 
kevp75Commented:
I can't find anything to the exactness of this issue, but I did run across one article, in which an image was being replaced with %20.  The fix was to use .CreateHTMLBody instead of .HTMLBody

However, that was a .mht file created using the Collabrative Data Objects... (so I don't hink it'll actually help in this instance...)
0
 
harigabbitaAuthor Commented:
I have fixed this problem by concatenating each line with VBCRLF. Now i am not getting any errors of this kind.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.