0
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?

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Srcee
0

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 by Mitja Bonca: n/a

0

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.

0

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).

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.