Sending an email via Google Apps SMTP Server c#
<p>I am currently developing an application in C# using WPF. </p>

<p>I need the program to be able to send an email to the users email account. The email needs to be sent through my own SMTP server which is using the free Google Apps version for email. </p>

<p>I have put the following code in order to send the message.</p>

<pre><code>try
        {
            SmtpClient smtpClient = new SmtpClient();
            smtpClient.Host = "smtp.gmail.com";
            smtpClient.Port = 465;
            smtpClient.Credentials = new NetworkCredential("myusername", "mypassword");
            smtpClient.EnableSsl = true;

            MailMessage message = new MailMessage();
            message.To.Add(getEmail());
            message.Subject = "Password Manager Sync Account Created";
            message.From = new MailAddress("username@domain.com");
            message.Body = "My Email message"
            smtpClient.Send(message);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error Occurred" + ex.Message, "Email Failed", MessageBoxButton.OK, MessageBoxImage.Error);
</code></pre>

<p>However, when this code runs it instead just displays an error to say that the operation timed out. </p>

<p>What could be wrong with this. Any help would be greatly appreciated.</p>
