Hello Everybody, I want to send a message to somebody email using C# I have the right code but when I run the application it shown the "ArgumentExecpt ion was unhandled" error, it is been yellow, it stop the application from running.
Here is the code:
The code is true, but it doesnt send, and it shown the yello error when the code arrived to "client.Send(me ssage)".
Can anyone help me.
Here is the code:
Code:
using System;
using System.Net.Mail;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string to = "myEmail@hotmail.com";
string from = "myEmail@hotmail.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "New Car";
message.Body = @"Hello Friend, I buy a new car today.";
SmtpClient client = new SmtpClient("MyServerName");
client.UseDefaultCredentials = true;
client.Send(message);
}
}
}
Can anyone help me.
Comment