import javax.mail.*; import javax.mail.internet.*; import java.net.*; import java.util.*; import javax.activation.*; class Kiri2{ public static void main(String argumendid[]) throws Exception{ Properties p1=System.getProperties(); p1.put("mail.smtp.host", "mail.tpu.ee"); Session s1=Session.getDefaultInstance(p1, null); Message teade=new MimeMessage(s1); teade.setFrom(new InternetAddress("jaagup@minitorn.tpu.ee")); teade.setRecipients(Message.RecipientType.TO, InternetAddress.parse("jaagup@tpu.ee, jaagup@minitorn.tpu.ee")); teade.setSubject("Pildiga tervitus"); MimeBodyPart sisu1=new MimeBodyPart(); sisu1.setText("Soovin sulle head päeva"); MimeBodyPart sisu2=new MimeBodyPart(); String pildinimi="pilt1.gif"; sisu2.setDataHandler(new DataHandler(new FileDataSource(pildinimi))); sisu2.setFileName(pildinimi); Multipart mp=new MimeMultipart(); mp.addBodyPart(sisu1); mp.addBodyPart(sisu2); teade.setContent(mp); teade.setSentDate(new Date()); Transport.send(teade); } }