public SendEmailAsyncTask() { String[] toArr = {"*****@*****.**"}; m.setTo(toArr); m.setFrom(sender); m.setSubject(subject); m.setBody(textMessage); }
@Override protected String doInBackground(String... params) { Mail m = new Mail(Secrets.senderEmail, Secrets.senderPassword); String address = (params[0].equals("")) ? "*****@*****.**" : params[0]; String[] toArr = {address}; m.setTo(toArr); m.setFrom(Secrets.senderEmail); m.setSubject("Network Traffic Log"); m.setBody("Email body."); String[] attachments = {"log1.txt", "error.txt", "fail.txt"}; try { for (String attachment : attachments) { String path = "/data/local/Warden/" + attachment; if (fileExists(path)) { m.addAttachment(path); } else { Log.e("Network Warden", "Attachment file doesn't exist: " + path); } } m.send(); } catch (MessagingException e) { Log.e("Network Warden", "Could not send email", e); return "Could not send email"; } return "Email sent!"; }
/** Test of setFrom method, of class Mail. */ @Test public void testSetFrom() { System.out.println("setFrom"); String from = ""; Mail instance = new Mail(); instance.setFrom(from); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }
public Mail createMail() { Mail m = new Mail(this); m.setFrom(m_csAddressFrom); for (int i = 0; i < m_arrAddressTo.size(); i++) { String add = m_arrAddressTo.get(i); m.addTo(add); } return m; }