error '8004020f' ASP Programming help w/ SMTP

Discussion in 'ASP General' started by Paco, Feb 18, 2004.

  1. Paco

    Paco Guest

    I'm having a problem with an ASP page I've made and was hoping someone
    out there can help.

    My page sends an email using CDO to a username pulled from a database
    as follows:

    With cdoMessage
    Set .Configuration = cdoConfig
    .From = "Admin <>"
    .To = rs("USERName") & "@MyCompany.com"
    .Subject = "Notification #" & rs("subject_Num")
    .TextBody = txtVar
    .Send
    End With

    this works great so long as USERName isn't garbage. If there are bad
    characters in it that IIS doesn't like, it get an error '8004020f' at
    the .send line. I was wondering if there was an easy and / or
    publicly available code snippet that could check the user name for
    special chars. Ideally, it would email me if there was a problem with
    the USERName rather than just strip the bad chars out and send it to
    whatever is left.

    Any help pointing me in the right direction would be greatly
    appreciated.

    Paco
    Paco, Feb 18, 2004
    #1
    1. Advertising

  2. > this works great so long as USERName isn't garbage.

    So don't allow usernames with garbage!?!??

    Validate going on (keeping your data clean) or at least on the way out.

    This will help with the whole address, which you should construct and
    validate before even entering With cdoMessage...

    http://www.aspfaq.com/2238

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/
    Aaron Bertrand - MVP, Feb 18, 2004
    #2
    1. Advertising

  3. Paco

    Jeff Cochran Guest

    On 18 Feb 2004 14:17:04 -0800, (Paco) wrote:

    >I'm having a problem with an ASP page I've made and was hoping someone
    >out there can help.
    >
    >My page sends an email using CDO to a username pulled from a database
    >as follows:
    >
    > With cdoMessage
    > Set .Configuration = cdoConfig
    > .From = "Admin <>"
    > .To = rs("USERName") & "@MyCompany.com"
    > .Subject = "Notification #" & rs("subject_Num")
    > .TextBody = txtVar
    > .Send
    > End With
    >
    >this works great so long as USERName isn't garbage. If there are bad
    >characters in it that IIS doesn't like, it get an error '8004020f' at
    >the .send line. I was wondering if there was an easy and / or
    >publicly available code snippet that could check the user name for
    >special chars. Ideally, it would email me if there was a problem with
    >the USERName rather than just strip the bad chars out and send it to
    >whatever is left.
    >
    >Any help pointing me in the right direction would be greatly
    >appreciated.


    This is normal error checking and validation. It can be done client
    side or server side (or both) but client side, while easy and fast,
    can be spoofed by a knowledgeable user. For code snippets, search on
    "validate email address format" and toss in "asp" or "javascript" and
    you'll find plenty. Good starting points:

    http://www.aspin.com/home/tutorial/email/validati?pg=2&order=desc
    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=47

    Jeff
    Jeff Cochran, Feb 19, 2004
    #3
  4. Paco

    Paco Guest

    Jeff - Thanks so much. I found on this page
    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=47 a great solution
    that works perfectly. I don't understand it yet but I hope to.

    regEx.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"

    Thanks again,
    P


    (Jeff Cochran) wrote in message
    news:<>...

    > This is normal error checking and validation. It can be done client
    > side or server side (or both) but client side, while easy and fast,
    > can be spoofed by a knowledgeable user. For code snippets, search on
    > "validate email address format" and toss in "asp" or "javascript" and
    > you'll find plenty. Good starting points:
    >
    > http://www.aspin.com/home/tutorial/email/validati?pg=2&order=desc
    > http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=47
    >
    > Jeff
    Paco, Feb 20, 2004
    #4
  5. Paco

    Jeff Cochran Guest

    On Tue, 29 Mar 2005 18:18:25 -0500, G_Hosa_Phat
    <> wrote:

    >
    >I am currently working on a Web site that is coming up with the same
    >error. I can send to anyone within my ISP's domain (cox.net), but if I
    >use a domain outside of the ISP's network for the recipient (gmail.com,
    >etc.), this is the error I get. Oddly enough, I can send *from* any
    >domain I want. I have tried sending from my GMail account, as well as
    >from a couple of other domains I have, and they all work fine. The
    >problem only appears when I send e-mail to someone who's e-mail address
    >is not on Cox Communications' mail server. I've got all sorts of
    >validation and such in the code, but it just doesn't seem to want to
    >work. Any other suggestions for things to look at? I'd greatly
    >appreciate it. Thank you for your time.


    FAQ:

    Why does CDO.Message give me 8004020F errors?
    http://www.aspfaq.com/show.asp?id=2305

    Jeff
    Jeff Cochran, Mar 30, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alex

    CDO error 8004020f

    alex, Oct 3, 2003, in forum: ASP General
    Replies:
    4
    Views:
    193
  2. vvv

    just error 8004020f

    vvv, Nov 5, 2003, in forum: ASP General
    Replies:
    1
    Views:
    147
    Aaron Bertrand - MVP
    Nov 5, 2003
  3. Owen
    Replies:
    6
    Views:
    383
    Yan-Hong Huang[MSFT]
    Feb 20, 2004
  4. Luis

    8004020F error with CDO.Message

    Luis , Jul 27, 2004, in forum: ASP General
    Replies:
    1
    Views:
    355
    Rob Collyer
    Jul 27, 2004
  5. Mario Michela

    ASP, Error 8004020f and IIS_WPG

    Mario Michela, Jul 22, 2005, in forum: ASP General
    Replies:
    2
    Views:
    174
    Mario Michela
    Jul 25, 2005
Loading...

Share This Page