I searched for hours using a variety of different phrases to try to find an AppleScript that didn't use GUI Scripting to change the network location in OS X. I couldn't find it, but I did finally find a tidbit in Apple's Developers documentation about scselect, which is a command-line application to change locations. I'm not sure if you need Developer Tools installed to use this or not, since I don't have a computer without them to test it on.
Replace acctName with the name of your account in Mail, change serverName to the name of your already-existing SMTP server in Mail. Replace locationName with the name of the Network location you want to switch to.
tell application "Mail" set smtp server of account "acctName" to smtp server "serverName" end tell tell application "Finder" do shell script "scselect locationName" end tell
Mac OS X Hints