| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Thu May 29, 2008 12:27 pm Post subject: [Help] help with sending e-mail in C# |
|
|
i saw a vb source of a program that sends emails and i tried to convert it to C#
but i keep getting the failed message, i cant see what's wrong here?
| Code: |
private void button1_Click(object sender, EventArgs e)
{
try
{
string host = String.Empty;
host = "SMTP.gmail.com";
MailMessage Mail = new MailMessage();
Mail.To.Add(To.Text);
Mail.From = new MailAddress(From.Text);
Mail.Subject = "lol";
Mail.Body = input.Text;
SmtpClient SMTP = new SmtpClient(host);
SMTP.Port = 587;
SMTP.Host = host;
SMTP.EnableSsl = true;
SMTP.Send(Mail);
SMTP = null;
Mail.Dispose();
MessageBox.Show("Success");
}
catch
{
MessageBox.Show("Failed");
}
}
|
btw i found an email sending class that was written by microsoft at msdn and it didnt worked for me either :\
EDIT:
i found out what's wrong
i need to use the
| Code: |
SMTP.Credentials = new System.Net.NetworkCredential(User.Text, Pass.Text);
|
but what if i dont want to use it ?
just to use "from" email and "To" email how can i do it?
_________________
Stylo |
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Thu May 29, 2008 12:49 pm Post subject: |
|
|
try putting
| Code: |
catch( Exception e )
{
MessageBox.Show( e.Message );
} |
I think that's right, it should show you the real error message.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Thu May 29, 2008 12:56 pm Post subject: |
|
|
yea i think i was right it's the user/pass information
view attachment
| Description: |
|
| Filesize: |
15.53 KB |
| Viewed: |
3675 Time(s) |

|
_________________
Stylo |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Thu May 29, 2008 2:09 pm Post subject: |
|
|
( About the exception: I usually like to just put e.ToString() )
Anyways,
You should Google for using GMail as your host, it's usually pretty easy to use.
_________________
|
|
| Back to top |
|
 |
|