5. public class Mail {
public void sendEmailWithCsvFile(String from, String to, String subject,
String body, List<String> csvFileLines) {
Properties props = new Properties();
props.put(quot;mail.smtp.hostquot;, quot;localhostquot;);
Session session = Session.getDefaultInstance(props);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
MimeBodyPart part1 = new MimeBodyPart();
part1.setText(body);
MimeBodyPart part2 = new MimeBodyPart();
StringBuffer buffer = new StringBuffer();
for (String line : csvFileLines)
buffer.append(line + quot;nquot;);
part2.setContent(buffer.toString(), quot;text/csvquot;);
part2.setFileName(quot;file.csvquot;);
Multipart mp = new MimeMultipart();
mp.addBodyPart(part1);
mp.addBodyPart(part2);
msg.setContent(mp);
Transport.send(msg); }
}
6. Message.RecipientType
I want this CSV
report delivered InternetAddress Multipart
as an e-mail
attachment
MimeMessage MimeBodyPart
Session Properties
11. public class Mail {
public void sendEmailWithCsvFile(String from, String to, String subject,
String body, List<String> csvFileLines) {
StringBuffer buffer = new StringBuffer();
for (String line : csvFileLines)
buffer.append(line + quot;nquot;);
Properties props = new Properties();
props.put(quot;mail.smtp.hostquot;, quot;localhostquot;);
MailService mailService = new MailService(props);
mailService.newMessage()
.from(from)
.to(to)
.subject(subject)
.body(body)
.attachTextFile(quot;file3.csvquot;, buffer.toString())
.send();
}
}
12. send_email do
to 'pcalcado@gmail.com'
from 'bemaia@fragmental.tw'
subject 'Testing via Ruby'
body %{
Hi,
Please do not forget the milk.
Bye!
}
attachment('file4.csv') << lines
end
13. I want this CSV E-mail
report delivered
as an e-mail
Attachment
attachment
16. Noise
the difference between
I want this CSV E-mail
report delivered
as an e-mail
Attachment
attachment
17. Noise
the difference between
I want this CSV E-mail
report delivered
This
as an e-mail
Attachment
attachment
18. Noise
the difference between
I want this CSV E-mail
report delivered
This That
as an e-mail
Attachment
attachment
19. Noise
the difference between
Business Analysis Design Implementation
public class Something{
Class Name Class Name
Attribute Attribute
Attribute Attribute
private String name;
Operation Operation
Operation Operation
public boolean doS(){
}
Class Name
Attribute
}
Attribute
Operation
Operation
This That
26. “Idiomatic”: Focus on how to use
technical tools to solve the
problem in an efficient way.
Domain-Driven: Language is only a
tool to model the domain.
Internal DSL: Language is only an
:internal {
extensible tool to model the
DSL
domain.
}
External DSL: Language is created
based on the domain.
27. “Idiomatic”: TFocus on how to use
DO: a
O e
e d r n am
technical toolsr thato solve the
Ne te
be t t
fo
problem in an efficient way.
Domain-Driven: Language is only a
tool to model the domain.
Internal DSL: Language is only an
:internal {
extensible tool to model the
DSL
domain.
}
External DSL: Language is created
based on the domain.