using System;
using Dimac.JMail;

namespace JMailTest
{
  class MainClass
  {
    [STAThread]
    static void Main( string[] args )
    {
      // create JMail message
      Message message = new Message();
      
      // set sender
      message.From.Email = "me@mydomain.com";

      // add a recipient
      message.To.Add( "myfriend@hisdomain.com" );

      // set the subject & body
      message.Subject = "Hello, world!";
      message.BodyText = "Hello, world! My hovercraft is full of eels.";

      // add an attachment
      message.Attachments.Add( "C:\\me_dancing.wmv" );

      // send the message
      try
      {
        Smtp.Send( message, "mail.mydomain.com" );

        Console.WriteLine( "The message has been sent." );
      }
      catch ( Exception ex )
      {
        Console.WriteLine( "Failed to send message: {0}", ex.Message );
      }
    }
  }
}