I found another website that lists web services you can consume in your VBA applications. WebserviceX.net
provides On Demand XML Web Services for Financial,Distribution, Retail, Health Care, Manufacturing, Telecom, Government and Educational Industry.
What this means for you is more stuff to do. Well, more stuff for your applications to do.
Let's use one web service: validating email addresses. I'm not talking about the formatting, but actually checking if the email address can be mailed.
The API at WebserviceX explains how to use it. Here's how the code works out:
Function IsValidEmail(emailAddress As String) As Boolean Dim xml As Object Dim result As String Set xml = GetMSXML xml.Open "GET", "http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email=" & emailAddress, False xml.Send result = xml.responsetext ' parse result for response IsValidEmail = (InStr(result, "true") > 0) End Function
The XML response looks like this:
<?xml version="1.0" encoding="utf-8"?> <boolean xmlns="http://www.webservicex.net">true</boolean>
The service returns true if the email address is valid; false if it isn't. So all we have to do is check for those in the result.
For the GetMSXML function, visit MSXML Object Library Routines.
Sample usage
Sub TestValidEmail()
Debug.Print IsValidEmail("asdf@asdf.com")
End Sub
I wonder, though, if this is a legit use for VBA?
Why isn't this a reasonable use for VBA?
I can imagine some lowly spammer using it to validate email addresses. But I suppose they can do it without my help.
I like this. Thanx for finding this.
Thanks JP for another great post. Some Access Database users send emails to their customers and this code could be quite helpful for maintaining a list of valid email addresses.