@Override /** * Create a string representation of this email address. * * @return A String that uses following format:<br/> * if personal part of email is available: "First Last <email@example.com>"<br/> * if only the address part is available: " */ public String toString() { String retval = getAddress(); if (getPersonal() != null && getPersonal().trim().length() > 0) { retval = "\"" + getPersonal() + "\" <" + getAddress() + ">"; } return retval; }
/** * Set the sender of this message. * * @param email * Email address of sender. */ public void setFrom(String email) { this.from = new EmailAddress(email); }
/** * Build a list of Strings from an email address list. Equivalent to iterating the list and * calling toString() on each element. * * @param emails * @return */ public static List<String> toStringList(List<EmailAddress> emails) { ArrayList<String> output = new ArrayList<String>(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.add(ea.toString()); } } return output; }
SubscriptionSender subscriptionSender = new SubscriptionSender(); subscriptionSender.setSubject("Lista degli utenti disattivati"); subscriptionSender.setBody(emailBody.toString()); subscriptionSender.setUserId(user.getUserId()); subscriptionSender.setCompanyId(user.getCompanyId()); subscriptionSender.setFrom("noreply@liferay.com", "Liferay Portal"); subscriptionSender.setHtmlFormat(false); subscriptionSender.setMailId("user", user.getUserId()); subscriptionSender.addRuntimeSubscribers( user.getEmailAddress(), user.getFullName()); List<EmailAddress> emails = (List<EmailAddress>) user.getEmailAddresses(); if (emails.size() > 0) { if (_log.isInfoEnabled()) { _log.info("User " + user.getUserId() + " has additional emails address"); } for (EmailAddress emailAddress : emails) { subscriptionSender.addRuntimeSubscribers( emailAddress.getAddress(), (String) user.getFullName()); } } subscriptionSender.flushNotificationsAsync();
String emailAdress = ""; for(EmailAddress address: emailsList){ emailAdress += address.getAddress(); emailAdress+=",";
@Override /** * Create a string representation of this email address. * * @return A String that uses following format:<br/> * if personal part of email is available: "First Last <email@example.com>"<br/> * if only the address part is available: " */ public String toString() { String retval = getAddress(); if (getPersonal() != null && getPersonal().trim().length() > 0) { retval = "\"" + getPersonal() + "\" <" + getAddress() + ">"; } return retval; }
/** * Set the sender of this message. * * @param email * Email address of sender. */ public void setFrom(String email) { this.from = new EmailAddress(email); }
/** * Build a list of Strings from an email address list. Equivalent to iterating the list and * calling toString() on each element. * * @param emails * @return */ public static List<String> toStringList(List<EmailAddress> emails) { ArrayList<String> output = new ArrayList<String>(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.add(ea.toString()); } } return output; }
try InternetAddress ia = new InternetAddress(email.getAddress(), true); ia.setPersonal(email.getPersonal()); laddrs.add(ia);
/** * Add a recipient to this message. * * @param type * How to address the recipient. * @param email * Email to send to. */ public void addRecipient(RecipientType type, String email) { List<EmailAddress> addresses = recipients.get(type); if (addresses == null) { addresses = new ArrayList<EmailAddress>(); } addresses.add(new EmailAddress(email)); recipients.put(type, addresses); }
/** * Turn a list of email addresses into a comma delimited String. The output format of each * entry is: "First Last" <email@address.tld> * * @param emails * @return */ public static String toString(List<EmailAddress> emails) { StringBuilder output = new StringBuilder(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.append(ea.toString()).append(", "); } // remove the extra trailing comma and space output.delete(output.length() - 2, output.length()); } return output.toString(); } }
from = new InternetAddress(msg.getFrom().getAddress(), true); from.setPersonal(msg.getFrom().getPersonal()); + msg.getFrom().getAddress(), msg.getFrom()); + msg.getFrom().getAddress(), msg.getFrom());
/** * Add a recipient to this message. * * @param type * How to address the recipient. * @param email * Email to send to. */ public void addRecipient(RecipientType type, String email) { List<EmailAddress> addresses = recipients.get(type); if (addresses == null) { addresses = new ArrayList<EmailAddress>(); } addresses.add(new EmailAddress(email)); recipients.put(type, addresses); }
/** * Turn a list of email addresses into a comma delimited String. The output format of each * entry is: "First Last" <email@address.tld> * * @param emails * @return */ public static String toString(List<EmailAddress> emails) { StringBuilder output = new StringBuilder(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.append(ea.toString()).append(", "); } // remove the extra trailing comma and space output.delete(output.length() - 2, output.length()); } return output.toString(); } }
/** * Add a recipient to this message. * * @param type * How to address the recipient. * @param name * Name of recipient. * @param email * Email to send to. */ public void addRecipient(RecipientType type, String name, String email) { List<EmailAddress> addresses = recipients.get(type); if (addresses == null) { addresses = new ArrayList<EmailAddress>(); } addresses.add(new EmailAddress(email, name)); recipients.put(type, addresses); }
private void sendEmail(User user, SignupEmailNotification email) { logger.debug("sendMail called for user:" + user.getEid()); try { EmailMessage message = convertSignupEmail(email, user); if(message != null) { emailService.send(message); } } catch (NoRecipientsException e) { logger.error("Cannot send mail. No recipient." + e.getMessage()); } catch (AddressValidationException e) { //this should be caught when adding the email address, since it is validated then. logger.warn("Cannot send mail to user: " + user.getEid() + ". Invalid email address." + EmailAddress.toString(e.getInvalidEmailAddresses())); } }
/** * Add a recipient to this message. * * @param type * How to address the recipient. * @param name * Name of recipient. * @param email * Email to send to. */ public void addRecipient(RecipientType type, String name, String email) { List<EmailAddress> addresses = recipients.get(type); if (addresses == null) { addresses = new ArrayList<EmailAddress>(); } addresses.add(new EmailAddress(email, name)); recipients.put(type, addresses); }
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010); service.Url = new Uri("https://<server>/EWS/Exchange.asmx"); EmailAddress emailAddress = new EmailAddress(); emailAddress.Address = "nick.wright@<domain>"; emailAddress.Name = String.Empty; OofSettings OOFSettings = new OofSettings(); OOFSettings.Duration = new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)); OOFSettings.ExternalAudience = OofExternalAudience.All; OofReply internalReply = new OofReply(); OofReply externalReply = new OofReply(); externalReply.Message = "This is my external OOF reply"; internalReply.Message = "This is my internal OOF reply"; OOFSettings.ExternalReply = externalReply; OOFSettings.InternalReply = internalReply; OOFSettings.State = OofState.Disabled; try { service.SetUserOofSettings("nick.wright@<domain>", OOFSettings); } catch (Exception ex) { }
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); ExchangeCredentials credentials = new WebCredentials("user", "pw"); service.setCredentials(credentials); service.setUrl(new URI("https:// s e r v e r /ews/exchange.asmx")); EmailAddress mEmail = new EmailAddress("your email / test email"); EmailMessage message = new EmailMessage(service); message.getToRecipients().add(mEmail); message.setFrom(mEmail); message.setSubject("Hello world!"); message.setBody(MessageBody.getMessageBodyFromText("Sent using the EWS Android API.")); message.send();
public static void sendMail(String[] addresses) throws Exception { // enter vaild mail id and password ExchangeCredentials credentials = new WebCredentials("mail_id", "passwd"); service.setCredentials(credentials); // enter vaild server url service.setUrl(new URI("server")); EmailMessage mail = new EmailMessage(service); mail.setSubject("Hello EWS Send"); mail.setBody(new MessageBody("pffed bye!!!")); for (String string : addresses) mail.getToRecipients().add(new EmailAddress(string)); mail.sendAndSaveCopy(); }