• (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

Sending e-mail messages using C# How to send e-mail messages using C# and WinForms.

#16 Guest_turqoil*


Reputation:

Posted 28 April 2010 - 05:58 PM

I got failure sending mail. The server is smtp.mail.yahoo.com.sg and port is 587. What is the problem?
Was This Post Helpful? 0

#17 Guest_Ed*


Reputation:

Posted 06 January 2011 - 06:37 AM

fyi guys, if you want to send email using hotmail you have to use the following code:

SmtpClient client = new SmtpClient("smtp.live.com");
MailMessage message = new MailMessage("a@bb.net", "lukyperson@somewhere.com");
message.Body = "Some text";
message.Subject = "A subject";

client.Credentials = new System.Net.NetworkCredential(Username, Password);
/*---->*/ client.Port = 587;
/*---->*/ client.EnableSsl = true;
client.Send(message);



Note the two key lines: port number is set to 587 and enablessl is set because hotmail uses SecureSocketsLayer on its connections. The email that is sent says :
From: [the server email account adress] on behalf of [name of person account is registered to] ([the email address you put as from i.e. a@bb.net])
This means you cannot create fake emails through Hotmail without the receiver knowing :)

Hope this helps, Ed

This post has been edited by JackOfAllTrades: 07 January 2011 - 06:40 AM

Was This Post Helpful? 0

#18 iconso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-March 11

Posted 18 March 2011 - 07:14 AM

If I get the error: Input string was not in a correct format.
How I can solve it?
Thanks for help.
Was This Post Helpful? 0
  • +
  • -

#19 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Posted 18 March 2011 - 07:37 AM

View Posticonso, on 18 March 2011 - 10:14 AM, said:

If I get the error: Input string was not in a correct format.
How I can solve it?
Thanks for help.


Care to provide the line of code where you receive the error?
Was This Post Helpful? 0
  • +
  • -

#20 iconso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-March 11

Posted 18 March 2011 - 07:45 AM

View Posteclipsed4utoo, on 18 March 2011 - 07:37 AM, said:

View Posticonso, on 18 March 2011 - 10:14 AM, said:

If I get the error: Input string was not in a correct format.
How I can solve it?
Thanks for help.


Care to provide the line of code where you receive the error?


catch (Exception ex)
{
//show error
MessageBox.Show("can't send message: "+ex.Message);
}

I receive this error from the exception, when I click on send button.
I'm a beginner with c#.
Was This Post Helpful? 0
  • +
  • -

#21 chirag.makwana1989  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 31-January 11

Posted 01 April 2011 - 03:35 AM

I am creating window application
when I am sending mail at that time error occur
Cannot sent Message : Failure sending mail.
can you tell me what is the problem in my code.

try
{
MailMessage mail = new MailMessage(txtfrom.Text, txtto.Text);
mail.From = new MailAddress(txtfrom.Text);
mail.To.Add(txtto.Text);
mail.Subject = txtsubject.Text;
mail.Body = txtmess.Text;
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.mycompanyid.net";
smtp.Port = 25;
NetworkCredential NetCrd = new NetworkCredential();
NetCrd.Domain = "ip";
NetCrd.UserName = "myid";
NetCrd.Password = "mypass";
smtp.UseDefaultCredentials = false;
smtp.Credentials = NetCrd;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail);
MessageBox.Show("Your Message Sent Successfully");
}
catch (Exception ee)
{
MessageBox.Show("Cannot send message: " + ee.Message);
}


Was This Post Helpful? 0
  • +
  • -

#22 minhkhanh62  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-June 11

Posted 02 June 2011 - 12:20 AM

me too. i can't send email. please contact to me.
*******REMOVED EMAIL ADDRESS******* thanks please please

The parameter 'from' cannot be an empty string.
Parameter name: from
MailMessage message = new MailMessage(sendFrom.Text, sendTo.Text);
Was This Post Helpful? 0
  • +
  • -

#23 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Posted 07 June 2011 - 01:05 PM

View Postminhkhanh62, on 02 June 2011 - 03:20 AM, said:

me too. i can't send email. please contact to me.
*******REMOVED EMAIL ADDRESS******* thanks please please

The parameter 'from' cannot be an empty string.
Parameter name: from
MailMessage message = new MailMessage(sendFrom.Text, sendTo.Text);


I think that error message is pretty self-explanatory. The From parameter(the first parameter) can't be blank.
Was This Post Helpful? 1
  • +
  • -

#24 minhkhanh62  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-June 11

Posted 07 June 2011 - 01:23 PM

i finished thanks 2 days ago^^
Was This Post Helpful? 0
  • +
  • -

#25 l.jessie1268  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-June 11

Posted 23 June 2011 - 07:20 PM

I somehow set my email Username, Password, Host and Port in web.config file.
When sending email, it actually send from the email I set.
Is it possible to not displaying my email but display "noreply@mydomain.com" to receiver?
Was This Post Helpful? 0
  • +
  • -

#26 minhkhanh62  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-June 11

Posted 23 June 2011 - 07:38 PM

View Postl.jessie1268, on 23 June 2011 - 07:20 PM, said:

I somehow set my email Username, Password, Host and Port in web.config file.
When sending email, it actually send from the email I set.
Is it possible to not displaying my email but display "noreply@mydomain.com" to receiver?


lol. i'm create successed ^^
Was This Post Helpful? 0
  • +
  • -

#27 l.jessie1268  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-June 11

Posted 25 June 2011 - 05:54 AM

View Postminhkhanh62, on 23 June 2011 - 07:38 PM, said:

View Postl.jessie1268, on 23 June 2011 - 07:20 PM, said:

I somehow set my email Username, Password, Host and Port in web.config file.
When sending email, it actually send from the email I set.
Is it possible to not displaying my email but display "noreply@mydomain.com" to receiver?


lol. i'm create successed ^^


Please advise. Thanks :)
Was This Post Helpful? 0
  • +
  • -

#28 minhkhanh62  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-June 11

Posted 25 June 2011 - 06:20 AM

View Postl.jessie1268, on 25 June 2011 - 05:54 AM, said:

View Postminhkhanh62, on 23 June 2011 - 07:38 PM, said:

View Postl.jessie1268, on 23 June 2011 - 07:20 PM, said:

I somehow set my email Username, Password, Host and Port in web.config file.
When sending email, it actually send from the email I set.
Is it possible to not displaying my email but display "noreply@mydomain.com" to receiver?


lol. i'm create successed ^^


Please advise. Thanks :)


i haven't upload yet ! pm me. yahoo messenger ! satthudaudoimu62 or minhkhanh62@gmail.com i'll send my source hiii thanks everybody. send gmail and attach file.
Was This Post Helpful? 0
  • +
  • -

#29 stunning  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 29-October 11

Posted 29 October 2011 - 03:45 AM

to the author..


what to write in send server,server port?how can i find that from my computer?
what to write in send from? user and password?which user id ??
Was This Post Helpful? 0
  • +
  • -

#30 Essel  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 118
  • Joined: 08-May 09

Posted 06 January 2012 - 06:13 AM

Please i need some clarification on this.I really don't understand this part smtp.Host = "mail.mycompanyid.net";.What is this really talking about is it looking for my machine name or which ESSEL-PC or localhost or is it for example i have an email at yahoo so in that case can i just write smtp.yahoo.com or.Please help me
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4