I have Outlook.com powered email on tiksn.com domain. I want to send an email but was not succeed. Here is the code.
Update: Here is the error message: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first
using (System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage())
{
mailMessage.From = new System.Net.Mail.MailAddress(Preference.Email.Default.SystemAddress);
mailMessage.To.Add(Preference.Email.Default.ContactAddress);
mailMessage.ReplyToList.Add(UserAddress);
mailMessage.Sender = UserAddress;
mailMessage.Subject = Subject;
mailMessage.IsBodyHtml = false;
mailMessage.Body = Message;
mailMessage.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.Delay | System.Net.Mail.DeliveryNotificationOptions.OnFailure | System.Net.Mail.DeliveryNotificationOptions.OnSuccess;
mailMessage.Priority = System.Net.Mail.MailPriority.Normal;
using (System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient())
{
smtpClient.Credentials = new System.Net.NetworkCredential(Preference.Email.Default.SystemAddress, Preference.Email.Default.SystemPassword);
smtpClient.DeliveryFormat = System.Net.Mail.SmtpDeliveryFormat.International;
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
//smtpClient.EnableSsl = true;
smtpClient.Host = "smtp.live.com";
smtpClient.Port = 25;
//smtpClient.Port = 587;
//smtpClient.Port = 465;
smtpClient.UseDefaultCredentials = false;
smtpClient.Send(mailMessage);
}
}