The exception shows that it's trying to use "localhost" for sending. That's because, unlike the first piece of code, it uses the SMTP host specified in the Properties you use to get the Session. You probably didn't specify any, so it defaults to local host.
You can solve this two ways:
1) Specify the SMTP host with key "mail.smtp.host". The authentication must be done through keys "mail.smtp.user" and "mail.smtp.pass" or an Authenticator.
2) Get a Transport object as in your first piece of code, then first call
saveChanges on the message and then use the Transport's non-static
sendMessage method:
Also, you don't send emails through Outlook this way. Outlook is the client written by Microsoft. Their server software is called
Exchange.