Outoing mail server chooser

I go to OSU and my outgoing mail server does not work on campus, but my campus provides me with one when I am on campus, so I want to create a script that runs every time I send mail. I have started the script to detect my IP range, but now I need it to actually choose the mail servers and run automatically when I send mail, which I don’t know how to do. Here is the code I have so far. Thanks in advance.

set myip to do shell script "ifconfig | grep 'broadcast' | awk '{print $6}'"
if (myip begins with "128.193.") then
	display dialog "OSU"
else
	display dialog "Not OSU"
end if

Maybe I need to clarify what I mean.

I need to know how to tell Mail to use a certain server.
I need to also know how to run this script when I send mail.

Anyone know how to do that?

Ok, I have almost got it, I just need one more piece of the puzzle.

Here is the code:

set myip to do shell script "ifconfig | grep 'broadcast' | awk '{print $6}'"
if (myip begins with "128.193.") then
	tell application "Mail" to set smtp server of every account to smtp server "mail.oregonstate.edu"
else
	tell application "Mail" to set smtp server of every account to smtp server "mail.comcast.net"
end if

I just need this script to run when I hit the send button, anyone know how to do that?