0

I have been working on for days for this problem. I have two buttons. One button is to send mails from Gmail to Gmail, another for Gmail to Hotmail.
I can send mails from my Gmail account to another Gmail account but something goes wrong while sending from my Gmail account to Hotmail.

..mailbox unavailable server..... server response 5.7.3 Requested action aborted; user not authenticated

After five days I am about to give up. I have checked releated threads on SO

  1. Send email via Hotmail to gmail
  2. Sending mail using Gmail

Plase don't mark as a duplicate.

private void gmailTogmail(object sender, EventArgs e)
{
    var mail = new MailMessage();
    var c = new MailAddressCollection { txtto.Text.Trim() };
    mail.From = new MailAddress(txtfrom.Text.ToLower().Trim());

    // mail.To.Add((c[0].Address));
    mail.To.Add(txtto.Text.ToLower());
    mail.Subject = "for hilk";
    mail.Body = "some heeeeeee";
    mail.IsBodyHtml = true;

    var smtp = new SmtpClient
    {
        Host = "smtp.gmail.com",
        Port = 587,
        Credentials = new NetworkCredential(txtfrom.Text.Trim(), txtpass.Text.Trim()),
        EnableSsl = true
    };

    smtp.Send(mail);
    MessageBox.Show("ok");
}

private void gmailToHotmail(object sender, EventArgs e)
{
     SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
        var mail = new MailMessage();
        mail.From = new MailAddress("mymail@gmail.com");
        mail.To.Add("mailSento@hotmail.com");
        mail.Subject = "Your Sub";
        mail.IsBodyHtml = true;
        //string htmlBody;
        //htmlBody = "HTML code";
        //mail.Body = htmlBody;
        SmtpServer.Port = 587;
        SmtpServer.Timeout = 5000;
        SmtpServer.UseDefaultCredentials = false;
        SmtpServer.Credentials = new System.Net.NetworkCredential("mymail@gmail.com", "Pass");
        SmtpServer.EnableSsl = true;
        SmtpServer.Send(mail);
        MessageBox.Show("ok");
}
Community
  • 1
  • 1
user3733078
  • 249
  • 2
  • 11

0 Answers0