我想在C#Windows應(yīng)用程序中創(chuàng)建一個(gè)用于發(fā)送電子郵件的應(yīng)用程序。我使用了smtp服務(wù)器,但是我不想設(shè)置網(wǎng)絡(luò)憑據(jù)。所以我將其設(shè)置為true。但是出現(xiàn)錯(cuò)誤。SMTP服務(wù)器需要安全連接,或者客戶端未通過(guò)身份驗(yàn)證。服務(wù)器響應(yīng)為:5.5.1需要身份驗(yàn)證。了解更多這是代碼:SmtpClient oClient = new SmtpClient();oClient.Host = "smtp.gmail.com";oClient.Port = 25;oClient.UseDefaultCredentials = true;oClient.Credentials = new System.Net.NetworkCredential();oClient.EnableSsl = true;MailMessage oMail = new MailMessage();oMail.To.Add(txtTo.Text.Trim());oMail.From = new MailAddress("testmail@gmail.com");oMail.Subject = txtSubject.Text;oMail.Body = txtBody.Text;oMail.IsBodyHtml = true;oClient.Send(oMail);MessageBox.Show("Mail Send");在這里,我將主機(jī)設(shè)置為gmail.com,我需要使用所有電子郵件服務(wù)提供商發(fā)送和接收郵件。那么如何設(shè)置主機(jī)和端口?
在Windows窗體中使用網(wǎng)絡(luò)憑據(jù)將郵件發(fā)送為true
三國(guó)紛爭(zhēng)
2020-02-02 15:27:39