Okay; I can't seem to send a mail message. I'm running this as a console application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace Email
{
class Program
{
static void EMail(string ToAddress, string Subject, string Body, string FromAddress, string Host, int Port, string Username, string Password)
{
System.Net.Mail.SmtpClient SMTPClient = new System.Net.Mail.SmtpClient(Host, Port);
System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
Message.To.Add(new System.Net.Mail.MailAddress(ToAddress));
Message.From = new System.Net.Mail.MailAddress(FromAddress);
Message.Body = Body;
Message.Subject = Subject;
SMTPClient.EnableSsl = true;
SMTPClient.Credentials = new System.Net.NetworkCredential(Username, Password);
SMTPClient.Send(Message);
SMTPClient.SendCompleted += new System.Net.Mail.SendCompletedEventHandler(FinishedSending);
}
static void FinishedSending(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
Console.WriteLine("DONE!");
}
static void Main(string[] args)
{
EMail("***********", "Hi!", "This is a test, Sent from a C# application.", "******", "smtp.gmail.com", 465, "****************", "**************");
Console.ReadLine();
}
}
}
I'm not getting any errors, I'm not recieving it in my gmail account, And it's not writing "DONE!". I have allowed port 465, outcoming and incoming. Telnetting smtp.gmail.com on port 465 results in a blank command prompt window. Thanks.