Sending Emails, Code Halts if invalid email Address (1 Viewer)

KevinM

Registered User.
Local time
Today, 04:36
Joined
Jun 15, 2000
Messages
719
I'm using CDOSYS and SMTP in a vb function to send emails via Ms Access 2003.

My code loops through a recordset an sends an email to the email address in the table.

However, all works fine until an invalid email address is encountered, at which point I get an 'Invalid address' error message and the code halts (obviously). BUT, if use 'On Error Resume Next' I get no error message but all consequtive emails are NOT sent.

How can I get the code to ignore the invalid email and carry on sending emails throughout the recordset?
 

Simon_MT

Registered User.
Local time
Today, 04:36
Joined
Feb 26, 2007
Messages
2,176
I would assume that the reason for the error is the construction of email address, i.e. the email address is malformed. I would first check your actual email addresses and perhaps put a flag call Unsubcribed and any wrong email addresses flag these as unsubscribed and test in your routine to only take those email Not Unsubscribed.

Simon
 

KevinM

Registered User.
Local time
Today, 04:36
Joined
Jun 15, 2000
Messages
719
We tested using an email address 'mynamexxxx@mydomain.ac.uk'

Only the added 'xxxx' makes it invalid so it's not actually 'malformed'.

The error message reports that the user does not exist.

It says 'The server rejected one or more mail recipient addresses: 550 Unknown User'.

What we can't understand is why we get an instant error message, how does it immediatley know it's invalid? If it was malformed then I would understand it.
 

Simon_MT

Registered User.
Local time
Today, 04:36
Joined
Feb 26, 2007
Messages
2,176
Where is your SMTP pointing to. I don't get this mail rejection rather loads of Bounced mail. Does the Mail server have REVERSE DNS?

We do a lot of emarketing, and I have never seen this error using SMTP > Windows 2003 Exchange Server.

Simon
 

neileg

AWF VIP
Local time
Today, 04:36
Joined
Dec 4, 2002
Messages
5,975
Since you're using a .ac address I guess that you are using an internal mail system. Guessing again, it's the mail server that is generating the error, not your Access application when it tries to validate the address using its own directory. I don't knwo enough about this type of system in programming terms to advise but I work in a organisation where the a validation failure like this results in a system halt.
 

KevinM

Registered User.
Local time
Today, 04:36
Joined
Jun 15, 2000
Messages
719
Thanks, yes it's an internal mailing system and the mail server is generating the error, although it gives the usual 'Debug, end' options.
I thought their might be a way of trapping or skipping it and continuing on with the code that loops through the recordset which calls the email vb function.
 

Simon_MT

Registered User.
Local time
Today, 04:36
Joined
Feb 26, 2007
Messages
2,176
The internal emails accounts should always be correct. If the external emails are incorrect you should get Bounced Emails. I would thought check for any malformed email accounts.

Simon
 

KevinM

Registered User.
Local time
Today, 04:36
Joined
Jun 15, 2000
Messages
719
I think the end user is concerned that some emails may not get sent if one invalid one halts proceedings. I think he may be using a mixture of internal and external email addresses, but more likey one or the other.

So if they were all external emails then the code would continue to excecute and you would just get the usual bounce back replies?
But not so if there's an invalid internal email. It's more likely to be a typo than be malformed.

Thanks again
 

Users who are viewing this thread

Top Bottom