Results 1 to 3 of 3

Thread: Send mail using Gmail SMTP

  1. #1
    Davisricky is offline Senior Member
    Join Date
    Dec 2009
    Posts
    331
    Rep Power
    3

    Default Send mail using Gmail SMTP

    I am working on one live project where I use asp.net as front end and SQL as backend. In my project I want send a mail using SMTP but my SMTP is not working that’s why I use Gmail SMTP but it also didn’t work .anybody knows how to send mail using Gmail SMTP. Hope that I will get the response sooner!

  2. #2
    Garcíarobine is offline Senior Member
    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    3

    Default

    Check the code given below which may solve your problem:

    Code:
    protected void Button1_Click(object sender, EventArgs e)
    {
      MailMessage mail = new MailMessage();
      mail.To.Add(“abc@gmail.com”);\sender E-mail ID
      mail.To.Add(“xyz@gmail.com”);\ Reciever E-mail ID
      mail.From = new MailAddress(“abc@gmail.com”)
      mail.Subject = "Email using Gmail";
    
      string Body = "Hi, this mail is to test sending mail"+ 
                    "using Gmail in ASP.NET";
      mail.Body = Body;
    
      mail.IsBodyHtml = true;
      SmtpClient smtp = new SmtpClient();
      smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
      smtp.Credentials = new System.Net.NetworkCredential
           ("YourUserName@gmail.com","YourGmailPassword");
    //Or your Smtp Email ID and Password
      smtp.EnableSsl = true;
      smtp.Send(mail);
    }

  3. #3
    RodríguezBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    322
    Rep Power
    3

    Default

    Try to understand following code given below which is solve your issue.

    Code:
    string from = "sdfineweb@gmail.com";
    string to = mailID;
    MailMessage mail = new System.Net.Mail.MailMessage();
    mail.To.Add(to);
    mail.From =new MailAddress(from, "SDFine Admin", System.Text.Encoding.UTF8);
    mail.Subject ="Login Details For SDFine";
    mail.SubjectEncoding = System.Text.Encoding.UTF8;
    mail.Body = Body;
    mail.BodyEncoding = System.Text.Encoding.UTF8;
    mail.IsBodyHtml =true;
    mail.Priority =MailPriority.High;
    SmtpClient client = new SmtpClient();
    //Add the Creddentials- use your own email id and password
    client.Credentials =new System.Net.NetworkCredential(from, "password");
    client.Port = 587;// Gmail works on this port
    client.Host ="smtp.gmail.com";
    client.EnableSsl =true; //Gmail works on Server Secured Layer
    try
    {  client.Send(mail);  }
    catch (Exception Ex) {
    string mat = Ex.ToString();  }

Similar Threads

  1. Send using Gmail
    By Camren Gray in forum Download Tools and Softwares
    Replies: 0
    Last Post: 10-22-2010, 06:40 PM
  2. How to send e-mail through JSP
    By Erick Ballmer in forum Programming
    Replies: 3
    Last Post: 07-04-2010, 06:06 AM
  3. Send mail in ASP.net
    By MartinWilson in forum General Internet Terms
    Replies: 2
    Last Post: 06-22-2010, 01:45 PM
  4. Send mail using VB.net
    By RogersNguyen in forum General Internet Terms
    Replies: 1
    Last Post: 05-07-2010, 01:52 PM
  5. Send mail in PHP
    By Davisricky in forum Programming
    Replies: 2
    Last Post: 04-26-2010, 01:29 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48