Tuesday, 16 October 2012

Email Sending in .Net

  try
        {
           string emailid=bikash6718@gmail.com
            MailMessage m = new MailMessage("munait723@gmail.com", emailid);

            m.Body = txtMessage.Text;
            m.IsBodyHtml = false;
            m.Subject = "Regarding Feedback";
            m.Priority = MailPriority.High;

            // SMPT settings
            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25);  // server name and port number 587
            smtp.UseDefaultCredentials = false;
            smtp.EnableSsl = true;
            smtp.Credentials = new NetworkCredential("munait723@gmail.com", "9861607319");

            smtp.Send(m);
            lblErrorMsg.Text = "Mail Send Successfully ";
            lblErrorMsg.ForeColor = Color.Green;
            Int64 FedId = FeedbackId;
            UpdateFeedback(FedId);
        }
        catch (Exception ex)
        {
            //"Send Email Failed ! ";
            lblErrorMsg.Text = "Mail Not Send Successfully";
            lblErrorMsg.ForeColor = Color.Red;
        }

No comments:

Post a Comment