J
John Straumann
Hi all:
I am trying to write some code to send an email from an Assembly file, and
found some examples on MSDN. However when I run the program (I am using a
console app for testing), the email does not send. I do not get an error,
but nothing gets sent. The code is pasted below, any and all help is greatly
appreciated.
I have changed the "to" address and the password for "no spam" reasons.
Thanks.
John.
static void Main(string[] args)
{
try
{
//MailMessage theMailMessage = new
MailMessage("(e-mail address removed)", "(e-mail address removed)");
MailMessage theMailMessage = new MailMessage();
theMailMessage.From = new MailAddress( "(e-mail address removed)" );
theMailMessage.To.Add( "(e-mail address removed)" );
theMailMessage.Subject = "This is an email";
theMailMessage.Body = "body email message here";
SmtpClient theClient = new SmtpClient("192.168.1.77", 25);
theClient.UseDefaultCredentials = false;
System.Net.NetworkCredential theCredential = new
System.Net.NetworkCredential("(e-mail address removed)", "******");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);
}
catch (Exception ex)
{
Console.WriteLine(" Error " + ex.ToString());
}
I am trying to write some code to send an email from an Assembly file, and
found some examples on MSDN. However when I run the program (I am using a
console app for testing), the email does not send. I do not get an error,
but nothing gets sent. The code is pasted below, any and all help is greatly
appreciated.
I have changed the "to" address and the password for "no spam" reasons.
Thanks.
John.
static void Main(string[] args)
{
try
{
//MailMessage theMailMessage = new
MailMessage("(e-mail address removed)", "(e-mail address removed)");
MailMessage theMailMessage = new MailMessage();
theMailMessage.From = new MailAddress( "(e-mail address removed)" );
theMailMessage.To.Add( "(e-mail address removed)" );
theMailMessage.Subject = "This is an email";
theMailMessage.Body = "body email message here";
SmtpClient theClient = new SmtpClient("192.168.1.77", 25);
theClient.UseDefaultCredentials = false;
System.Net.NetworkCredential theCredential = new
System.Net.NetworkCredential("(e-mail address removed)", "******");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);
}
catch (Exception ex)
{
Console.WriteLine(" Error " + ex.ToString());
}