Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the same computer at home and at work. Each time I want to send an email, I have to change the account's SMTP server (to set ISP or local network one).

Is there a way to programmatically change this, or is there a buit-in option in Outlook 2010 which would do that?

share|improve this question
up vote 2 down vote accepted

First figure out the IP address of both your work's SMTP server, and home's SMTP server that you normally use to access them.

Check in Outlook and set it to use you work's SMTP server by name.

Head to \windows\system32\drivers\etc, and make a copy of your HOSTS file (name it HOSTS.2 or something).

Edit the first HOSTS file, and add and entry for the SMTP server's name (from Outlook), with your work's IP address for that server.

Edit the other to add the same Server name entry, but put your ISP's SMTP IP in instead.

You can then create a batch file to rename/swap the files, something like:

ren HOSTS. HOSTS.bak
ren HOSTS.bak HOSTS.2

Then you can just run the batch and it will swap HOSTS files, which will cause the server name to point to whichever IP is in the active HOSTS file.

If you are running Windows 7 you can go further by creating two batch files (one to make the home HOSTS active, and one to make the work HOSTS active) and then create two Scheduled Tasks that are set to trigger on login (or alike), but only if connected to a specific network:

Task Scheduler

Then, when you log in it will check to see which network you are attached to and run the proepr HOSTS rename batch file for that network.

share|improve this answer
Good tip! I will try to make a batch which rewrites specified line in HOSTS, instead of swaping between HOSTS file. – Velcro Dec 2 '11 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .