Results 1 to 2 of 2

Thread: I couldnot send email from widnows application using C#?

  1. #1
    Addicted Member
    Join Date
    Mar 07
    Posts
    200

    Resolved I couldnot send email from widnows application using C#?

    I want to send email from windows application using C#, i am developing my project on my laptop, i am connected to internet when i try to send email it fails to send here is the code i have.
    Code:
    private void button1_Click(object sender, EventArgs e)
            {
     
                try
                {
                    MailMessage mail = new MailMessage();
                    mail.To.Add("email1@gmail.com");
                    mail.To.Add(txtto.Text.ToString());
                    mail.From = new MailAddress("email2@gmail.com");
                    mail.Subject = "School Name";
                    string Body = txtmsg.Text;
                    mail.IsBodyHtml = true;
     
                    SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
                    smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address  
                    smtp.Credentials = new System.Net.NetworkCredential
                         ("simemail@gmail.com", "test12");
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.EnableSsl = true;
                    smtp.Send(mail);
                    MessageBox.Show("Mail Send");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
    my app.cong
    HTML Code:
    <configuration>
      <system.net>
        <mailSettings>
          <smtp deliveryMethod="network">
            <network defaultCredentials="false" host="smtp.gmail.com" port="587" username="simemail@gmail.com" password="test123"/>
          </smtp>
        </mailSettings>
      </system.net>
    </configuration
    i really want to send email from my windows application using C#, please help me

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,655

    Re: I couldnot send email from widnows application using C#?

    "when i try to send email it fails" -- sigh... you do realize with that statement, what you have done is walk into the doc's office and said "it hurts" ... and expect him to figure it out, right? You wouldn't do that now would you? since you have given no further details, then I can only assume that either your fingers fell off, or you've got eels in your hovercraft... or possibly both...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •