The other option is to use third party SMTP server software. One of such applications is smtp4dev available at http://smtp4dev.codeplex.com/. It is nice, because:
- No installation required (standalone executable is available)
- No setup required
- Messages are not being delivered and can be previewed locally in the SMTP server using smtp4dev GUI
In order to test email sending functionality, run this snippet:
using System.Net.Mail; namespace Sender { class Program { static void Main(string[] args) { MailMessage message = new MailMessage(); message.To.Add("recipient@test.com"); message.From = new MailAddress("sender@test.com"); message.Subject = "Message Subject"; message.Body = "Message Body"; SmtpClient smtp = new SmtpClient("localhost"); smtp.Send(message); } } }
No comments:
Post a Comment