Отправьте Эмиля с помощью учетной записи yahoo и Гамиля из C# winform
привет всем, я делаю приложение, которое отправляет электронную почту из yahoo mail в gmail и yahoo mail.
когда я отправляю Эмиля с помощью своей учетной записи gamil, он работает нормально, но когда я пытаюсь отправить Эмиля с помощью своей учетной записи yahoo mail, он выдает ошибку, пожалуйста, кто-нибудь мне поможет.
когда я использую этот код для отправки Эмиля с помощью своей учетной записи yahoo он выдает мне ошибку
сообщение об ошибке следует
"
sending system.net.mail.smptException mailbox unavilable. the server response was requested mail action not taken mailbox unavilable
"
Что я уже пробовал:
Я использую этот код
private void SmptTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (SmptTypecomboBox1.SelectedIndex == 0) { portno =587; servicetype = "smtp.gmail.com"; } if (SmptTypecomboBox1.SelectedIndex == 1) { portno = 587; servicetype = "smtp.mail.yahoo.com"; } }
private void Sendbutton1_Click(object sender, EventArgs e) { using (OpenFileDialog attachement = new OpenFileDialog() { Filter = "Pdf Files|*.pdf", ValidateNames = true }) { if (attachement.ShowDialog() == DialogResult.OK) { if (Isvalid()) { Send(FromtextBox.Text, paswordtextBox.Text, TotextBox.Text, MessagetextBox.Text, AttachmenttextBox6.Text, servicetype, portno, attachement.FileName); } } } // clearAllfileds(); }
public void Send(string from, string password, string to, string Message, string subject, string host, int port, string file) { MailMessage email = new MailMessage(); email.From = new MailAddress(from); email.To.Add(to); email.Subject = subject; email.Body = Message; SmtpClient smtp = new SmtpClient(host, port); smtp.UseDefaultCredentials = false; NetworkCredential nc = new NetworkCredential(from, password); smtp.Credentials = nc; smtp.EnableSsl = true; email.IsBodyHtml = true; email.Priority = MailPriority.Normal; email.BodyEncoding = Encoding.UTF8; if (file.Length > 0) { Attachment attachment; attachment = new Attachment(file); email.Attachments.Add(attachment); } // smtp.Send(email); smtp.SendCompleted += new SendCompletedEventHandler(SendCompletedCallBack); string userstate = "sending ..."; smtp.SendAsync(email, userstate); } private static void SendCompletedCallBack(object sender, AsyncCompletedEventArgs e) { string result = ""; if (e.Cancelled) { MessageBox.Show(string.Format("{0} send canceled.", e.UserState), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (e.Error != null) { MessageBox.Show(string.Format("{0} {1}", e.UserState, e.Error), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("your message is send", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }