Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

error

$
0
0

hi, i have done a windows application for sending mail when i am executing the application it is executing perfectly but when iam clicking on the send button in the run time it is showing in a message box that "the specifies string is not in the form required for an email address". please clarify nd tell me how to execute that application

the code is:

private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                SmtpClient client = new SmtpClient("smtp.gmail.com",587);
                client.EnableSsl = true;
                client.Timeout = 10000;
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials = new NetworkCredential("tutsstore4fb@gmail.com", "willbe123");
                MailMessage msg = new MailMessage();
                msg.To.Add("txtTo.Text");
                msg.From = new MailAddress("tutsstore4fb@gmail.com");
                msg.Subject = txtSbjct.Text;
                msg.Body = txtMsg.Text;
                client.Send(msg);
                MessageBox.Show("message sent succesfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>