addImage.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Mail m = new Mail("gmailusername@gmail.com", "password"); m.setTo(toArr); m.setFrom("wooo@wooo.com"); m.setSubject("This is an email sent using my Mail JavaMail wrapper from an Android device."); m.setBody("Email body."); m.addAttachment("/sdcard/filelocation"); if(m.send()) { Toast.makeText(MailApp.this, "Email was sent successfully.", Toast.LENGTH_LONG).show(); } else {
Configuration cfg = new Configuration(); ContextTemplateLoader loader = new ContextTemplateLoader(getContext(),"war:///WEB-INF"); cfg.setTemplateLoader(loader); TemplateRepresentation rep = null; Mail mail = new Mail(); //The data object you wish to populate - example from Restlet itself mail.setStatus("received"); mail.setSubject("Message to self"); mail.setContent("Doh!"); mail.setAccountRef(new Reference(getReference(), "..").getTargetRef() .toString()); Map<String, Object> data = new HashMap<String, Object>(); data.put("status", mail.getStatus()); data.put("subject", mail.getSubject()); data.put("content", mail.getContent()); data.put("accountRef", mail.getAccountRef()); rep = new TemplateRepresentation("Mail.ftl", cfg, data, MediaType.TEXT_HTML); return rep;
private void sendEmail() { Mail mail = new Mail(); mail.setToMail("to mail address"); mail.setSubject("Subject"); mail.setMailDescription("Description"); mail.addAttachment("file path")// if attachment is there try { mail.send(); } catch (Exception e) { e.printStackTrace(); Log.v(Email_Tag, ""+e); } }
@Override public void sendEmail(Mail mail) throws MailException { Preconditions.checkNotNull(mail.getFrom(), "Cannot send a message without a from address"); message.setFrom(new InternetAddress(mail.getFrom())); for (String to : mail.getTo()) { message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); for (String cc : mail.getCc()) { message.addRecipient(Message.RecipientType.CC, new InternetAddress(cc)); for (String bcc : mail.getBcc()) { message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc)); message.setSubject(mail.getSubject()); if (mail.getAttachments().size() == 0) { if (mail.getText() != null) { message.setText(mail.getText()); if (mail.getHtml() != null) { message.setContent(mail.getHtml(), "text/html; charset=utf-8"); if (mail.getText() != null) { messageBodyPart.setText(mail.getText()); if (mail.getHtml() != null) { messageBodyPart.setContent(mail.getHtml(), "text/html; charset=utf-8");
for (InviteItem item : items) { Mail mail = new Mail("test@test.com", "MYPASSIFORGOTTOCHANGE"); to = ((com.plan.library.contact.Invite) item) .get_email(); invitees.add(to); String body = html.replace("<%EMAIL%>", to); mail.set_to(to); mail.set_from("test@test.com"); mail.set_subject(name + " has invited"); mail.set_body(body); result = mail.send(); mail = null; }
public void onPreExecute() { this.m = new Mail("user@gmail.com", ""); String[] toArr = {"bla@bla.com", "lala@lala.com"}; m.setTo(toArr); m.setFrom("wooo@wooo.com"); m.setSubject("This is an email sent using my Mail JavaMail wrapper from an Android device."); m.setBody("Email body."); } }
Mail m1 = new Mail(); Mail m2 = new Mail() XStream xstream = new XStream(); xstream.alias("brokermail",Mail.class); m1.setInvoiceReferenceNotificationMessage(invoiceReferenceNotificationMessage1); m2.setInvoiceReferenceNotificationMessage(invoiceReferenceNotificationMessage2); String abc1 = xstream.toXML(m1); String abc2 = xstream.toXML(m2);
public class SendTask extends AsyncTask<String, Integer, Integer> { private ProgressDialog dialog; private Context mContext; public SendTask(Context mContext){ this.mContext = mContext; } protected void onPreExecute() { this.dialog = new ProgressDialog(mContext); this.dialog.setCancelable(false); this.dialog.setMessage("sending"); this.dialog.show(); } protected Integer doInBackground(String... ids) { Mail mail = new Mail(); try { mail.send(); } catch (Exception e) { e.printStackTrace(); } return 1; }
Mail m = new Mail(); m.addInvoiceReferenceNotificationMessages(invoiceReferenceNotificationMessagest); XStream xstream = new XStream(); xstream.alias("brokermail", Mail.class); xstream.processAnnotations(Mail.class); String abc = xstream.toXML(m); System.out.println(abc);
@Override public MailTemplate text(String subject) { super.text(subject); return this; }
@Override public MailTemplate subject(String subject) { super.subject(subject); return this; }
@Override public MailTemplate addAttachment(MailAttachment attachment) { super.addAttachment(attachment); return this; }
@Override public MailTemplate from(String from) { super.from(from); return this; }
@Override public MailTemplate to(String... to) { super.to(to); return this; }
log("Send mail " + mailObject.getSubject());
public void onPreExecute() { m = new Mail("user@gmail.com", "");
Mail m1 = new Mail(); XStream xstream = new XStream(); xstream.alias("brokermail",Mail.class); m1.setInvoiceReferenceNotificationMessage(invoiceReferenceNotificationMessage1); String abc1 = xstream.toXML(m1); m1.setInvoiceReferenceNotificationMessage(invoiceReferenceNotificationMessage2); String abc2 = xstream.toXML(m1);