I'm not sure which .NET version is required for this because eglasius mentioned there is no matching enableSsl
setting (I'm using .NET 4.0, but I suspect it to work in .NET 2.0 or later), but this configuration justed worked for me (and doesn't require you to use any programmatic configuration):
<system.net>
<mailSettings>
<smtp from="[email protected]" deliveryMethod="Network">
<network defaultCredentials="false" enableSsl="true" host="smtp.gmail.com" port="587" password="password" userName="[email protected]"/>
</smtp>
</mailSettings>
</system.net>
You might have to enable POP or IMAP on your Gmail account first: https://mail.google.com/mail/?shva=1#settings/fwdandpop
I recommend trying it with a normal mail client first...