I am trying to send an email with Asp.Net but the email will not always be sent using the same WIFI credentials.
string email = "noreply@sender.com";
string subject = "Subject";
string MailContent = "This is the content";
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient();
mail.To.Add(email);
mail.From = new MailAddress("noreplay@reciever.com");
mail.Subject = subject;
mail.IsBodyHtml = true;
mail.Body = MailContent;
SmtpServer.Host = "smtpserver";
SmtpServer.Port = 25;
SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
try
{
SmtpServer.Send(mail);
}
catch (Exception ex)
{
MessageBox.Show("Exception Message: " + ex.Message);
if (ex.InnerException != null)
MessageBox.Show("Exception Inner: " + ex.InnerException);
}
I tried using this code, which was found on a different question but still can't seem to get an error. Any alternative can work, I have a pdf which would like to be sent on an email or even one drive if possible. Thanks