Here is a minimal C# example using System.Net.Mail, which is the standard SMTP client in .NET. Replace the host, credentials and addresses with your own provider's settings.
using System.Net;
using System.Net.Mail;
var message = new MailMessage("[email protected]", "[email protected]")
{
Subject = "Test message",
Body = "Hello from C#.",
IsBodyHtml = false
};
using var client = new SmtpClient("smtp.example.com", 587)
{
EnableSsl = true,
Credentials = new NetworkCredential("[email protected]", "your-app-password")
};
client.Send(message);
A few notes. Port 587 with STARTTLS (EnableSsl = true) is the common modern choice. Most providers require an app-specific password rather than your normal login. Store credentials in configuration or a secrets store, not in source code. SmtpClient is considered legacy by some in the .NET community, so for production work MailKit is a popular third-party alternative with better protocol support. Also, use SendAsync or SendMailAsync if you don't want to block a UI or request thread.
If you tell me which .NET version and provider you're using, I can tailor the settings. Others who have wrestled with SMTP timeouts or TLS errors are welcome to add what worked for them.