harigabbita
asked on
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("toaddre ss"))
CCaddress = Trim(request.Form("ccaddre ss"))
comment = Trim(request.Form("ta_comm ent"))
EmailUrl = "http://mysite/mycontent/default.aspx?"
EmailUrl = EmailUrl & "id=536&En=456&pr=10021023 "
Set objCDO = Server.CreateObject("CDO.M essage")
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?
Here is the code:
<%
Dim objCDO 'cdosys
Dim EmailUrl
Dim strBody
Dim comment
Dim Toaddress
Dim CCaddress
Toaddress = Trim(request.Form("toaddre
CCaddress = Trim(request.Form("ccaddre
comment = Trim(request.Form("ta_comm
EmailUrl = "http://mysite/mycontent/default.aspx?"
EmailUrl = EmailUrl & "id=536&En=456&pr=10021023
Set objCDO = Server.CreateObject("CDO.M
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
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?
ASKER
I have tried that one. But getting the same kind of error.
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
ASKER
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.
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("toaddre ss"))
CCaddress = Trim(request.Form("ccaddre ss"))
comment = Trim(request.Form("ta_comm ent"))
EmailUrl = "http://mysite/mycontent/default.aspx?"
EmailUrl = EmailUrl & "id=536&En=456&pr=10021023 "
' Set objCDO = Server.CreateObject("CDO.M essage")
' 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:schema s:httpmail :importanc e").Value = 2
'objCDO.Fields.Update()
' objCDO.Send
Response.Write "Mail sent!"
' set objCDO = nothing
%>
<%
Dim objCDO 'cdosys
Dim EmailUrl
Dim strBody
Dim comment
Dim Toaddress
Dim CCaddress
Toaddress = Trim(request.Form("toaddre
CCaddress = Trim(request.Form("ccaddre
comment = Trim(request.Form("ta_comm
EmailUrl = "http://mysite/mycontent/default.aspx?"
EmailUrl = EmailUrl & "id=536&En=456&pr=10021023
' Set objCDO = Server.CreateObject("CDO.M
' 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:schema
'objCDO.Fields.Update()
' objCDO.Send
Response.Write "Mail sent!"
' set objCDO = nothing
%>
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
ASKER
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.
ok...the issue is not with your code. It is an issue with the users email clients
ASKER
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 ?
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 ?
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?
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...)
However, that was a .mht file created using the Collabrative Data Objects... (so I don't hink it'll actually help in this instance...)
ASKER
I have fixed this problem by concatenating each line with VBCRLF. Now i am not getting any errors of this kind.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
EmailUrl = "http://mysite/mycontent/default.aspx?id=536&En=456&pr=10021023"