I'm using the following code which appears to work perfectly every time on Vista/Win7.
private void SendEmail(string subject, string body, string attach)
{
using (MailMessage message = new MailMessage("[email protected]", "[email protected]", subject, body))
{
message.IsBodyHtml = true;
if (!string.IsNullOrEmpty(attach))
{
Attachment attached = new Attachment(attach);
message.Attachments.Add(attached);
}
SmtpClient client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "password"),
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network
};
client.Send(message);
}
}
However on Windows XP I'm getting:
No connection could be made because the target machine actively refuses it
I've checked and Windows firewall is completely disabled...