public static Mail buildDynamicTemplate ( ) throws IOException { Mail mail = new Mail ( ) ; Email fromEmail = new Email ( ) ; fromEmail . setName ( "Example User" ) ; fromEmail . setEmail ( "test@example.com" ) ; mail . setFrom ( fromEmail ) ; mail . setTemplateId ( "d-c6dcf1f72bdd4beeb15a9aa6c72fcd2c" ) ; Personalization personalization = new Personalization ( ) ; personalization . addDynamicTemplateData ( "name" , "Example User" ) ; personalization . addDynamicTemplateData ( "city" , "Denver" ) ; personalization . addTo ( new Email ( "test@example.com" ) ) ; mail . addPersonalization ( personalization ) ; return mail ; }
API V3 Dynamic Template implementation