Ejemplo n.º 1
0
 public SendEmailAsyncTask() {
   String[] toArr = {"*****@*****.**"};
   m.setTo(toArr);
   m.setFrom(sender);
   m.setSubject(subject);
   m.setBody(textMessage);
 }
Ejemplo n.º 2
0
    @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 setTo method, of class Mail. */
 @Test
 public void testSetTo() {
   System.out.println("setTo");
   String to = "";
   Mail instance = new Mail();
   instance.setTo(to);
   // TODO review the generated test code and remove the default call to fail.
   fail("The test case is a prototype.");
 }
Ejemplo n.º 4
0
  public void envoiMail() {

    mail.setCorp(
        "hi , "
            + pers.getNom()
            + " "
            + pers.getPrenom()
            + " Ask you if you like to participate in his new Event ");
    mail.setTo(pers.getMail());
    mail.send();
    FacesMessage message =
        new FacesMessage(FacesMessage.SEVERITY_INFO, "Confirmation Msg", "Invitation sent.");
    RequestContext.getCurrentInstance().showMessageInDialog(message);
  }