Moyosoft Products | Services | Download | Contact us    
Java Bridge to Exchange
import java.io.*;

import com.moyosoft.exchange.*;
import com.moyosoft.exchange.mail.*;

public class SendMailWithAttachment
{
  public static void main(String[] argsthrows ExchangeServiceException, IOException
  {
    // To provide hostname and credentials information, use:
    // Exchange exchange = new Exchange("hostname", "username", "password");
    Exchange exchange = ExchangeConnectionDialog.display();

    if(exchange == null)
    {
      return;
    }

    // Create a new e-mail:
    ExchangeMail mail = exchange.createMail();

    // Set the recipient, subject and body:
    mail.setToRecipient("info@moyosoft.com");
    mail.setSubject("Test message");
    mail.setBody("Hello. There's a message sent from Java.");
    
    // Add a new file attachment:
    mail.getAttachments().add(new File("C:\\attachment.txt"));
    
    // Send the message:
    mail.send();
  }
}