So far this is what i've tried, I want to send an email to our school email account with format of [email protected] or something like [email protected]. I'm sure that this is an outlook account so I took the smtp settings for outlook, but when I do this I keep on encountering the following error:
Failure sending mail.
What am I doing wrong here? I already search for the error but all of the answers are showing same syntax with mine except for the smtp settings. So there must be something wrong with my smtp settings for outlook.
SmtpClient smtpClient = new SmtpClient("smtp-mail.outlook.com", 25); //587 smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "myPassword"); smtpClient.UseDefaultCredentials = true; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.EnableSsl = true; MailMessage mail = new MailMessage(); mail.From = new MailAddress("[email protected]", "CTMIS-no-reply"); mail.To.Add(new MailAddress("[email protected]")); mail.CC.Add(new MailAddress("[email protected]")); smtpClient.Send(mail);