A developer is passed in with values and this method used to work but stopped suddenly. I dont recall changing anything that would have a direct impact in the Gmail API. Please help I need to show this to a employer tomorrow.
...
public void SendEmail(Developer developer)
{
var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
var loggedInEmployer = _context.Employers.Where(e => e.IdentityUserId ==
userId).SingleOrDefault();
var fromEmail = loggedInEmployer.Email;
var toEmail = developer.Email;
var fromAddress = new MailAddress(fromEmail, loggedInEmployer.UserName);
var toAddress = new MailAddress(toEmail, developer.UserName);
string fromPassword = MyKeys.passcode;
const string subject = "Hired On DevWorks";
string body = "Congratulations " + loggedInEmployer.UserName + " Has Hired you for contract at " + loggedInEmployer.CompanyName + "!";
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message2 = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message2);
}
}
...
question from:
https://stackoverflow.com/questions/65601467/my-gmail-api-suddenly-stopped-sending-emails-through-my-application-in-asp-net 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…