how can i send an email frm c# pls?

Recommended Answers

All 5 Replies

didnt work

private void RecovaryEmail(string username)
        {
            ManagerUserAccount mgrUserAccount = new ManagerUserAccount();
            UserAccount ua = mgrUserAccount.SearchUserAccount(username);

            ManagerStaff mgrStaff = new ManagerStaff();
            Staff s = mgrStaff.SearchStaff(ua.StaffID);


            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("anna.marie.rapa@gmail.com");
                mail.To.Add(s.Email);//members email
                mail.Subject = "Password Recovary";
                mail.Body = "Dear " + s.FirstName + " " + s.LastName + ",\nIn this email you have your account details.\n\nUsername: " + ua.Username + "\nPassword: " + ua.Password + "\nRecovery Question: " + ua.SecurityQuestion + "\nRecovery Answer: " + ua.SecurityAnswer + ".";

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("anna.marie.rapa@gmail.com", "anna.marie.rapa");
                SmtpServer.EnableSsl = true;
                SmtpServer.Host = "smtp.gmail.com";

                SmtpServer.Send(mail);
                MessageBox.Show("mail Send");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

givng me an error
the smtp server requires a secure connection or the client was not authenticated the response was....

I'd say your username/password are not correct in line 21.

I'd also not post them in a public forum.

I'd say your username/password are not correct in line 21.

I'd also not post them in a public forum.

thats right :) thx solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.