Метод, который я использую: "
Код: Выделить всё
protected void SendEmail(object sender, EventArgs e)
{
try
{
// Get input values
string recipient = txtRecipient.Text.Trim();
string subject = txtSubject.Text.Trim();
string message = txtMessage.Text.Trim();
// Email credentials
string fromAddress = "admin@gisworld.co.in";
string password = "xxxxxx"; // Replace with secure storage
// Configure SMTP client
SmtpClient smtpClient = new SmtpClient("mail.gisworld.co.in", 587)
{
Credentials = new NetworkCredential(fromAddress, password),
EnableSsl = false
};
// Create mail message
MailMessage mailMessage = new MailMessage
{
From = new MailAddress(fromAddress),
Subject = subject,
Body = message,
IsBodyHtml = false
};
mailMessage.To.Add(recipient);
// Send email
smtpClient.Send(mailMessage);
lblStatus.Text = "Email sent successfully!";
}
catch (Exception ex)
{
lblStatus.Text = $"An error occurred: {ex.Message}";
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ry-time-it
Мобильная версия