Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP MXLookUp(host) help

    Hello,

    I am having some an issue with some free code that i found on the net. It is the MXLookUp code for ASP. This checks to see if a domain is a valid mail server. Here is the error that i am getting...


    3/21/2007 1:17:01 PM || ******* || COM Error Number: (0x800A000D) || File Name: /profile.asp || Line Number: 549 || Brief Description: Type mismatch: 'CInt' ||


    and here is the code, the bold line is the line that has the error...


    function MXLookUp(host)
    MXLookUp = false
    dim objXMLHTTP, strResult
    set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")

    objXMLHTTP.Open "Get", _
    "http://examples.softwaremodules.com/IntraDns.asp?domainname=" & host & "&Submit=Submit&t_mx=1", False
    objXMLHTTP.Send
    strResult = objXMLHTTP.ResponseText
    strResult = Mid(strResult,InStr(strResult,"(MX) for <strong>"),100)
    strResult = Mid(strResult,Instr(strResult,"</strong>. Items Returned: <strong>")+35,1)

    '*********** THIS IS WHERE THE MAILER SECTION IS FAILING. ******************
    if CInt(strResult) > 0 then
    MXLookUp = true
    else
    validateEmail("Email address host does not exist. Please enter a valid email address.")
    end if
    end function



    Any help on this error would be great. I do know that the field it is returning is a String subtype so I guess what i need to do is know how to convert this to the CInt. Thanks in advance.

  • #2
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did find out that the main script is pulling a "t" back instead of a number like it is supposed to do. The code is supposed to pull out anything from 0 on up but for some reason i am getting a letter "t" back...

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Look at the page you're trying to rip this data from:

    http://examples.softwaremodules.com/...gle.com&t_mx=1

    All you're doing is grabbing the source code for this page and running some fairly unsophisticated string functions on it. If you look at the source code for the section in question, they've got an awful lot of comment code around there - I dunno if that's a recent addition but it may well be throwing your script out of line. You can either amend your existing script so it starts counting characters from a different place or, ideally, take that bit out and run a RegExp on objXMLHTTP.ResponseText to get the values you want.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    By the way, you shouldn't use Microsoft.XMLHTTP, use something like MSXML2.XMLHTTP. Microsoft.XMLHTTP is old and buggy (particularly if you use it more than a few times per day)

  • #5
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Im sorry, I guess i should have said this from the start. i am very familari with ColdFusion but I am new to ASP. I am looking up the MSXML2.XMLHTTP but I dont understand what spudhead was speaking of. This is the code that another programmer was working on and im just trying to get it to function as it should. Any detailed explainations or tutorials would be great as the original tutorial on this does not speak of the error.

    Where else should the code start?

    I did also take out the comment line but still having the same issue...

    function MXLookUp(host)
    MXLookUp = false
    dim objXMLHTTP, strResult
    set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")

    objXMLHTTP.Open "Get", _
    "http://examples.softwaremodules.com/IntraDns.asp?domainname=" & host & "&Submit=Submit&t_mx=1", False
    objXMLHTTP.Send
    strResult = objXMLHTTP.ResponseText
    strResult = Mid(strResult,InStr(strResult,"(MX) for <strong>"),100)
    strResult = Mid(strResult,Instr(strResult,"</strong>. Items Returned: <strong>")+35,1)

    if CInt(strResult) > 0 then
    MXLookUp = true
    else
    validateEmail("Email address host does not exist. Please enter a valid email address.")
    end if
    end function


    -------------------------------\
    THE ERROR:

    3/22/2007 1:20:48 PM || jwinkler || COM Error Number: (0x800A000D) || File Name: /cora_extranet/profile.asp || Line Number: 547 || Brief Description: Type mismatch: 'CInt' ||

    Line number 547 is the line that is in bold above.

    Thanks.
    Last edited by jwinkler; 03-22-2007 at 07:19 PM.

  • #6
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Ok. Do you know what this bit of code is actually doing? What an XMLHTTP request is?

    Firstly, these two lines:

    objXMLHTTP.Open "Get", _
    "http://examples.softwaremodules.com/IntraDns.asp?domainname=" & host & "&Submit=Submit&t_mx=1", False
    objXMLHTTP.Send


    All this is doing is telling your ASP page to go and make a HTTP GET request for that page. So if you call your function and pass in "google.com", then your function goes and gets this page here.

    With the next line, strResult = objXMLHTTP.ResponseText, it loads the entire source code for that page into a variable called strResult.

    Then it just does a couple of string functions on that chunk of source code to try and find the bit you need:

    strResult = Mid(strResult,InStr(strResult,"(MX) for <strong>"),100)

    So - find the bit that reads "(MX) for <strong>" and take 100 characters starting there.

    strResult = Mid(strResult,Instr(strResult,"</strong>. Items Returned: <strong>")+35,1)

    Then, from that new string, find "</strong>. Items Returned: <strong>", count forwards 35 characters and take the next one. In this case that should be the number "4".

    Except that it isn't. Look at the source code for that page. The bit you need is down here:

    Code:
    <tr>
    	<td><hr><font face="Arial" size="2">
    	DNS Lookup (MX) for <strong>google.com</strong>. Items <block class='9560'> <!--- 8731762'>llsk<./RnJIgQmFzZW6529134QgRE5TIExv<!zIG14IGx481227vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//8624948/';lkkjsRnJlZSBXZWI6849574gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd9519906 --->Returned: <block class='1509'> <!--- 8197695'>llsk<./RnJIgQmFzZW8131333QgRE5TIExv<!zIG14IGx5674627vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//3044746/';lkkjsRnJlZSBXZWI8278598gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd2577042 ---><strong><block class='4993'> <!--- 7744531'>llsk<./RnJIgQmFzZW4179241QgRE5TIExv<!zIG14IGx7530905vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//4820121/';lkkjsRnJlZSBXZWI5608265gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd588040 --->4</strong><br>
    	<li><block class='8304'> <!--- 7810893'>llsk<./RnJIgQmFzZW6635947QgRE5TIExv<!zIG14IGx160787vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//9586268/';lkkjsRnJlZSBXZWI3965615gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd8171785 --->smtp2.google.com <block class='2898'> <!--- 4031977'>llsk<./RnJIgQmFzZW3284283QgRE5TIExv<!zIG14IGx5527363vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//6142332/';lkkjsRnJlZSBXZWI8985840gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd3111108 --->- MX Priority:<block class='3391'> <!--- 5206923'>llsk<./RnJIgQmFzZW7103652QgRE5TIExv<!zIG14IGx6101881vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//1762987/';lkkjsRnJlZSBXZWI4779670gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd8385411 ---> 10<br><li><block class='2257'> <!--- 5954616'>llsk<./RnJIgQmFzZW4860572QgRE5TIExv<!zIG14IGx2831120vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//8919478/';lkkjsRnJlZSBXZWI654402gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd761216 --->smtp3.google.com <block class='441'> <!--- 1402095'>llsk<./RnJIgQmFzZW8518135QgRE5TIExv<!zIG14IGx7170014vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//8558586/';lkkjsRnJlZSBXZWI4392868gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd6890025 --->- MX Priority:<block class='6743'> <!--- 9840346'>llsk<./RnJIgQmFzZW547589QgRE5TIExv<!zIG14IGx1081655vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//9479455/';lkkjsRnJlZSBXZWI4286054gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd7210465 ---> 10<br><li><block class='5781'> <!--- 2724306'>llsk<./RnJIgQmFzZW9239918QgRE5TIExv<!zIG14IGx9693082vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//3645175/';lkkjsRnJlZSBXZWI9133104gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd13522 --->smtp4.google.com <block class='2684'> <!--- 4672856'>llsk<./RnJIgQmFzZW8705851QgRE5TIExv<!zIG14IGx1295282vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//8838575/';lkkjsRnJlZSBXZWI6208694gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd1442547 --->- MX Priority:<block class='5741'> <!--- 5501452'>llsk<./RnJIgQmFzZW908480QgRE5TIExv<!zIG14IGx7343189vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//694853/';lkkjsRnJlZSBXZWI7984069gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd8772213 ---> 10<br><li><block class='3752'> <!--- 8812664'>llsk<./RnJIgQmFzZW974842QgRE5TIExv<!zIG14IGx9799895vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//3324735/';lkkjsRnJlZSBXZWI2750217gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd7129562 --->smtp1.google.com <block class='1336'> <!--- 6061429'>llsk<./RnJIgQmFzZW4540132QgRE5TIExv<!zIG14IGx3792439vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//6035519/';lkkjsRnJlZSBXZWI9306280gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd2149788 --->- MX Priority:<block class='6275'> <!--- 3899253'>llsk<./RnJIgQmFzZW5715079QgRE5TIExv<!zIG14IGx267600vb2t1cCwgaXA----14IGxvb2t1cA==//';lkkjsud:3/26/2007 7:24:04 AM :llsk<.//9265828/';lkkjsRnJlZSBXZWI4926934gQmFzZWQgt1cD'as'd;asd;a'sd;;as;da's'';ogbG9vt1cA==dyyw67udd5287825 ---> 10<br></td>
    
    </tr>
    See all those comments? That's what is screwing up your function. It's not expecting them to be there, and they're putting its character counting out of whack. I'm not sure what they're there for - it's conceivable that they're there exactly for the purpose of stopping people leeching their free content. But that's what you need to get around.

  • #7
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thats strange becauses that is what the intention of the site is for, for a free dns lookup and they even provide the code for it. I will look more into the other method, this is the code that the othe rprogrammer was trying to use. Thanks for all your input on this!

  • #8
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are having problems with that site then you can easily adapt your code to use another site that offers mx lookups.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •