?
Solved

Space in the Hyperlink in the Email body - CDOSYS

Posted on 2007-07-26
14
Medium Priority
?
358 Views
Last Modified: 2008-03-10
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?
0
Comment
Question by:harigabbita
  • 7
  • 5
13 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 19576712
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
 

Author Comment

by:harigabbita
ID: 19576818
I  have tried that one. But getting the same kind of error.
0
 
LVL 25

Expert Comment

by:kevp75
ID: 19576883
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:harigabbita
ID: 19576954
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
 
LVL 25

Expert Comment

by:kevp75
ID: 19577023
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
 
LVL 25

Expert Comment

by:kevp75
ID: 19577037
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
 

Author Comment

by:harigabbita
ID: 19577250
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
 
LVL 25

Expert Comment

by:kevp75
ID: 19577384
ok...the issue is not with your code.  It is an issue with the users email clients
0
 

Author Comment

by:harigabbita
ID: 19577797
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
 
LVL 25

Expert Comment

by:kevp75
ID: 19577869
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
 
LVL 25

Expert Comment

by:kevp75
ID: 19577975
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
 

Author Comment

by:harigabbita
ID: 19655322
I have fixed this problem by concatenating each line with VBCRLF. Now i am not getting any errors of this kind.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21091519
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question