MailMessage msg = new MailMessage("myAddress@hotmail.com", txtTo.Text, txtSubject.Text, txtBody.Text);
SmtpClient client = new SmtpClient("something");
client.Send(msg);

Both the address "to" and "from" are hotmail addresses.
Instead of "something" I tried pop3.live.com and smtp.live.com, but they both didn't work. Can someone help me?

And I have a second question. If my "from" e-mail address was hotmail, and my "to" e-mail address was gmail for example, in the constructor of SmtpClient - should I use value for hotmail or gmail?

Check this example code, it works well:

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("emails to send to(multiple are seperated by comma");
message.Subject = "subject";
message.From = new System.Net.Mail.MailAddress("Mail From -you email");
message.Body = "body text"
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("userName, "password"); //write username and pswd if your email has it
smtp.Send(message);

Edited 5 Years Ago by Mitja Bonca: n/a

Check this example code, it works well:

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("emails to send to(multiple are seperated by comma");
message.Subject = "subject";
message.From = new System.Net.Mail.MailAddress("Mail From -you email");
message.Body = "body text"
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("userName, "password"); //write username and pswd if your email has it
smtp.Send(message);

Okay, first - it doesn't work well, it gives me the same exception as my code.
And second, I don't want gmail. I want hotmail.

You want to send actually from a hotmail (like in my example from gmail)?
I dont actually know the data needed for hotmail, you have to get it by your own (try checking on your hotmail account for Host, and Port properties).

You want to send actually from a hotmail (like in my example from gmail)?
I dont actually know the data needed for hotmail, you have to get it by your own (try checking on your hotmail account for Host, and Port properties).

As I already said, I want to sedn e-mail from hotmail account to hotmail account.
How to check for the data?

This article has been dead for over six months. Start a new discussion instead.