/** * Set the sender of this message. * * @param email * Email address of sender. */ public void setFrom(String email) { this.from = new EmailAddress(email); }
/** * Set the sender of this message. * * @param email * Email address of sender. */ public void setFrom(String email) { this.from = new EmailAddress(email); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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) { }
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(); }
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();
ExchangeService mailbox = new ExchangeService(ExchangeVersion.Exchange2007_SP1); mailbox.setUrl(new URL("https://remote.domain.com/EWS/exchange.asmx").toURI()); ExchangeCredentials credentials = new WebCredentials("user.name", "password", "domain"); mailbox.setCredentials(credentials); ExtendedPropertyDefinition titlePropDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String); Contact c = new Contact(mailbox); c.setGivenName("GivenName"); c.setSurname("Surname"); c.getEmailAddresses().setEmailAddress(EmailAddressKey.EmailAddress1, new EmailAddress("asdf@asdf.com")); c.setExtendedProperty(titlePropDef, "TitleXYZ"); c.save(WellKnownFolderName.Contacts); Contact result = (Contact) mailbox.findItems(WellKnownFolderName.Contacts, new ItemView(1)).iterator().next(); PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties); propertySet.add(titlePropDef); result = Contact.bind(mailbox, result.getId(), propertySet); System.out.println("count: " + result.getExtendedProperties().getCount()); for(ExtendedProperty p : result.getExtendedProperties()) { System.out.println(p.toString()); }
public void sendEmail(String body, String subject, String recipients, String from) { service = new ExchangeService(); ExchangeCredentials credentials = new WebCredentials(username, password); service.setCredentials(credentials); service.setUrl(ewsUri); try { EmailMessage replymessage = new EmailMessage(service); EmailAddress fromEmailAddress = new EmailAddress(from); replymessage.setFrom(fromEmailAddress); replymessage.getToRecipients().add(recipients); //replymessage.setInReplyTo(recipients); replymessage.setSubject(subject); replymessage.setBody(new MessageBody(body)); replymessage.send(); }catch (Exception e) { logger.error(""+e); } }
public class Main { /** * @param args */ public static void main(String[] args) throws Exception { ExchangeService exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); ExchangeCredentials credentials = new WebCredentials("myusername","mypassword", "mydomain"); exchangeService.setCredentials(credentials); exchangeService.setUrl(new URI("https://myhostname/EWS/Exchange.asmx")); exchangeService.setTraceEnabled(true); EmailMessage msg; msg = new EmailMessage(exchangeService); msg.setFrom(new EmailAddress("myuser@myserver.com")); msg.setSubject("Test Mail"); msg.getToRecipients().add("myuser@gmail.com"); msg.setBody(MessageBody.getMessageBodyFromText("Email sent by Miscrosoft Java EWS API.")); msg.getAttachments().addFileAttachment("c:\\temp\\myattachement.pdf"); msg.send(); }
EmailAddress emailAddress = new EmailAddress();
EmailAddress emailAddress = new EmailAddress();