@@ -38,15 +38,14 @@ private void runApp() throws SparkPostException, IOException {
3838 this .client = this .newConfiguredClient ();
3939
4040 // Loads an email to send from the file system
41- String template = getTemplate ("sample_sp_email.eml" );
4241 String fromAddress = getFromAddress ();
4342 String [] recipients = getTestRecipients ();
4443
45- sendEmail (fromAddress , recipients , template );
44+ sendEmail (fromAddress , recipients );
4645
4746 }
4847
49- private void sendEmail (String from , String [] recipients , String email ) throws SparkPostException {
48+ private void sendEmail (String from , String [] recipients ) throws SparkPostException {
5049 TransmissionWithRecipientArray transmission = new TransmissionWithRecipientArray ();
5150
5251 // Populate Recipients
@@ -58,16 +57,19 @@ private void sendEmail(String from, String[] recipients, String email) throws Sp
5857 }
5958 transmission .setRecipientArray (recipientArray );
6059
61- transmission .setReturnPath (from );
62-
6360 // Populate Substitution Data
6461 Map <String , Object > substitutionData = new HashMap <String , Object >();
65- substitutionData .put ("from " , from );
62+ substitutionData .put ("yourContent " , "You can add substitution data too." );
6663 transmission .setSubstitutionData (substitutionData );
6764
6865 // Populate Email Body
6966 TemplateContentAttributes contentAttributes = new TemplateContentAttributes ();
70- contentAttributes .setEmailRFC822 (email );
67+ contentAttributes .setFrom (new AddressAttributes (from ));
68+ contentAttributes .setSubject ("Your subject content here. {{yourContent}}" );
69+ contentAttributes .setText ("Your Text content here. {{yourContent}}" );
70+ contentAttributes .setHtml ("<p>Your <b>HTML</b> content here. {{yourContent}}</p>" );
71+ transmission .setContentAttributes (contentAttributes );
72+
7173 transmission .setContentAttributes (contentAttributes );
7274
7375 // Send the Email
0 commit comments