I Could not understand what is happening on my code. When i try to send an email to another email address it keeps on sending on my gmail account.
eg.
From:xxx@gmail.com
to: yyy@yahoo.com
The email which supposed to be sent on yyy@yahoo.com, instead it send to xxx@gmail.com.
here is my code. I used gmail server on this.
private void btnSend_Click(object sender, EventArgs e)
{
try
{
MailMessage mail=new MailMessage();
MailAddress myAddress = new MailAddress(txtFrom.Text);
MailAddress myReceipient = new MailAddress(txtTo.Text);
mail.From = myAddress;
mail.To.Add(myReceipient.Address);
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
client.Host = "smtp.gmail.com";
client.Port = 587;
client.Credentials = new NetworkCredential("xxx@gmail.com","<somepassword>");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Send(mail);
MessageBox.Show("Message Sent");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}