Link to home
Start Free TrialLog in
Avatar of OzoneFriendly
OzoneFriendly

asked on

How do I check for a valid email address before sending?

Hello experts;

I have an Access database with code that sends out emails, the pointy end of the code looks like;

                        Set objOutlookRecip = objOutlookMsg.Recipients.Add(clientemail)
                        objOutlookRecip.Type = olTo
                        objOutlookMsg.Send

The problem is sometimes people have entered invalid email addresses, and when it gets to the send line, the code breaks.

How do I check BEFORE sending that the email address is valid according to Outlook?
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of OzoneFriendly
OzoneFriendly

ASKER

Cool, I'll try and implement one of those solutions and get back to you. I was hoping there was a simple "outlook" command to do it, but this is cool. :-)

Out of interest, would any of these validate as okay the following string;

email1@domain.com; email2@domain.com

I know some instances might be formatted like that, which Outlook WILL accept, but will that code?
Mine wont, It will only process an email at a time.
If you add recipients one at a time, no, passing >1 address will not work.  However, this will:    objOutlookMsg.To = "addr1@foo.com;addr2@foo.com;addr3@foo.com"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Basically, you cannot check if an email address is valid, but you can check if it is proper in "form" e.g someone@domain.tld

1 either you connect to the email domain server and check
2. try sending the email, some servers will reject the email if the email is not balid (ie, does not exist)

To check for valid form, use regular expression
check here for example

http://www.vbforums.com/showthread.php?t=559741&highlight=valid+email+regex
I will check out these options and see which one will work in my situation soon. Thanks for the advice.
I really must get around to trying these solutions. I've been soooo busy. :-(
>> I really must get around to trying these solutions

As far as I see, all possible solutions are provided.
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.