MailWrapper { public void sendWithAttachment(String to, String subj, String body, QrHolder attachment) throws Exception { client.sendHtmlWithAttachment(to, subj, body, new QrHolder[] {attachment}); } MailWrapper(MailProperties mailProperties, String productName); void sendReportEmail(String to,
                                String subj,
                                String downloadUrl,
                                String dynamicSection); void sendText(String to, String subj, String body); void sendHtml(String to, String subj, String body); void sendWithAttachment(String to, String subj, String body, QrHolder attachment); void sendWithAttachment(String to, String subj, String body, QrHolder[] attachments);  }
@Test @Ignore public void sendMailForStaticProvisioning() throws Exception { String body = "Hi there,<br>\n" + "<br>\n" + "Nice app you made with Blynk!<br>\n" + "<br>\n" + "Here is what's next:\n" + "\n" + "<ul>\n" + " <li>For Static Provisioning you need to upload Auth Tokens provided in this email to your devices. Tokens are in the attachment.</li>\n" + "\n" + " <li>During the provisioning process, device will be connected to your network. You need to scan provided QRs in order to connect your app to devices. Learn <a href=\"http: "</ul>\n" + "\n" + "<b>If you would like to publish your app to App Store and Google Play, check out our <a href=\"https: "<br>\n" + "Let’s build a connected world together!<br>\n" + "<br>\n" + "--<br>\n" + "<br>\n" + "Blynk Team<br>\n" + "<br>\n" + "<a href=\"https: "<br>\n" + "<a href=\"https: QrHolder[] qrHolders = new QrHolder[] { new QrHolder(1, 0, "My device", "12345678901", QRCode.from("21321321").to(ImageType.JPG).stream().toByteArray()), new QrHolder(1, 1, "My device2", "12345678902", QRCode.from("21321321").to(ImageType.JPG).stream().toByteArray()) }; MailProperties properties = new MailProperties(Collections.emptyMap()); try (InputStream classPath = MailWrapperTest.class.getResourceAsStream("/mail.properties")) { if (classPath != null) { properties.load(classPath); } } MailWrapper mailWrapper = new MailWrapper(properties, AppNameUtil.BLYNK); mailWrapper.sendWithAttachment("dmitriy@blynk.cc", "yo", body, qrHolders); }
@Test @Ignore public void sendMailWithAttachments() throws Exception { MailProperties properties = new MailProperties(Collections.emptyMap()); try (InputStream classPath = MailWrapperTest.class.getResourceAsStream("/mail.properties")) { if (classPath != null) { properties.load(classPath); } } QrHolder qrHolder = new QrHolder(1, 0, "device name", "123", QRCode.from("123").to(ImageType.JPG).stream().toByteArray()); QrHolder qrHolder2 = new QrHolder(1, 1, "device name", "123", QRCode.from("124").to(ImageType.JPG).stream().toByteArray()); String to = "doom369@gmail.com"; MailWrapper mailWrapper = new MailWrapper(properties, AppNameUtil.BLYNK); mailWrapper.sendWithAttachment(to, "Hello", "Body!", new QrHolder[]{qrHolder, qrHolder2}); }