?
Solved

CDO Message + trap invalid mail addresses

Posted on 2004-08-23
13
Medium Priority
?
495 Views
Last Modified: 2008-01-09
Hi.

I use CDO to send activation codes to new members of my password protected site. Now, sometimes people get funny and submit addresses that don't exist, meaning I get a "Mail not delivered" mail back. Sometimes I need to remind people that haven't activated their accounts that they should do so, meaning I've written a script that takes stuff out of the database and mails a reminder to the members who haven't activated their account. But if someone has entered a faulty mail address, the script of course stops givng me an error and stops the execution.

I somehow need to trap this event and just skip that particular mail and jump to the next.

How is this done?
0
Comment
Question by:bobamatics
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 11876221
Send email through regex first:

Function RegExpTest(sEmail)
  RegExpTest = false
  Dim regEx, retVal
  Set regEx = New RegExp

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

  ' Set pattern:
  regEx.IgnoreCase = true

  ' Set case sensitivity.
  retVal = regEx.Test(sEmail)

  ' Execute the search test.
  If not retVal Then
    exit function
  End If

  RegExpTest = true
End Function

If it returns tru then it is good, and you should send.  This check email address format, not whether the address exists.  No easy to check if exists.
0
 

Author Comment

by:bobamatics
ID: 11876253
I already have a function to check if the address is in a valid format, what I need is being able to trap when the script halts due to the error given by the mail server.

The error is 8004020f and means "The transport failed to connect to the server." which in this case means it couldn't be sent because the mail address doesn't even exists.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876260
Don't think ASP will do that...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:alorentz
ID: 11876268
Using "on error resume next" will not work in this situation either.  however this error should not stop the script, it will effect SMTP and badmail, but the script should continue.
0
 
LVL 31

Accepted Solution

by:
alorentz earned 400 total points
ID: 11876277
CDO script doesn't care if the email doesn't exist.  SMTP will just send to badmail, and may send Admin email to your domain account.  But ASP should run through all names in DB.
0
 

Author Comment

by:bobamatics
ID: 11876335
Ok, I tried to mail to an address I know doesn't exist, and you're right, it sends it anyway.

But then I have no idea why it halts at certain addresses. Seems there not much I can do about it then?
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876417
No idea why it would halt?

Maybe on nulls, or if there's a space in the address.  But if there anything else in it "jdoe@jdoe.com", "sss", whatever, it will not stop the script.  Check for nulls or spaces in the email.
0
 

Author Comment

by:bobamatics
ID: 11876517
That's the thing, I ran the script four times with slight modifications inbetween and got the error message. Then I checked my inbox and saw four "Undelivered Mail Returned to Sender" mails.

I do trim(strEmail) when I put in the address in the database...so it should send them. Is there a limit on how many requests a mail server will accept at once or something? I use my ISP:s SMTP server and try to loop 30 mails in the execution of the page.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876546
Yes, they may block the amount of email that can be sent...to prevent spamming.  Many ISP's do check for this sort of thing.

However, TRIM won't work on somthing like this "jdoe@ jdoe.com".  That will kill the script because of the internal space.

But, most likely this is a problem because you ISp is not allowing all those emails at the same time.  MAy want to limit to 10 or so.
0
 

Author Comment

by:bobamatics
ID: 11876581
Now I Response.Wrote the id:s after the mails had been sent and checked where it stopped. And it stopped mostly on faulty addresses, like whatever@hotmail.co (isn't co a top domain?) and _blah_@domain.com where _ isn't allowed as a starting character. But liiiinda@hotmail.com wasn't accepted. Very strange.

Oh well, I've got most of the mails away now, and your answer was correct so have the points and thanks for your time and help :)
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876637
Good luck!
0
 

Author Comment

by:bobamatics
ID: 11876652
Isn't it strange that it halts on michel_kt@hotail.com if it doesn't know that doesn't exists? Just wondering...it clearly looks like a misspelling to me.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876684
I still don't know why the script would stop, but CDO may validate on domain name. MS may have incorporated this functionality into the new CDOSYS component.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

771 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