protected ExchangeService initializeIfNecessary(ProcessContext context) throws ProcessException { ExchangeVersion ver = ExchangeVersion.valueOf(context.getProperty(EXCHANGE_VERSION).getValue()); ExchangeService service = new ExchangeService(ver); final String timeoutInMillis = String.valueOf(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS)); service.setTimeout(Integer.parseInt(timeoutInMillis)); String userEmail = context.getProperty(USER).evaluateAttributeExpressions().getValue(); String password = context.getProperty(PASSWORD).evaluateAttributeExpressions().getValue(); ExchangeCredentials credentials = new WebCredentials(userEmail, password); service.setCredentials(credentials); Boolean useAutodiscover = context.getProperty(USE_AUTODISCOVER).asBoolean(); if(useAutodiscover){ try { service.autodiscoverUrl(userEmail, new RedirectionUrlCallback()); } catch (Exception e) { throw new ProcessException("Failure setting Autodiscover URL from email address.", e); } } else { String ewsURL = context.getProperty(EWS_URL).getValue(); try { service.setUrl(new URI(ewsURL)); } catch (URISyntaxException e) { throw new ProcessException("Failure setting EWS URL.", e); } } return service; }
ExchangeService exchange = new ExchangeService(); service.AutodiscoverUrl("myemail@mycompany.com"); service.Credentials = new NetworkCredential("myemail", "mypassword", "MYDOMAIN");
@Autowired public ExchangeCalendarProvider(MailService mailService) { this.mailService = mailService; this.exchangeService = new ExchangeService(); }
ExchangeService exchange = new ExchangeService(); exchange .AutodiscoverUrl("myemail@mycompany.com"); exchange .Credentials = new NetworkCredential("myemail", "mypassword", "MYDOMAIN");
ExchangeService service = new ExchangeService(); ExchangeCredentials credentials = new WebCredentials("user@domain.com","pass");
ExchangeService service = new ExchangeService(); //login to your exchange server with credentials etc & set your service url ..... //issue your search for a given user using EmailMesssageSchema.From FindItemsResults <Item> results = service.findItems(WellKnownFolderName.Inbox, new SearchFilter.IsEqualTo(EmailMessageSchema.From, "SomeUser"), new ItemView(100));
ExchangeService service = new ExchangeService(); ExchangeCredentials credentials = new WebCredentials( "username", "pass"); service.setCredentials( credentials ); service.setUrl( new URI("http://your/wsdlUrl.asmx?wsdl") );
ExchangeService service = new ExchangeService();
ExchangeService service = new ExchangeService(); ExchangeCredentials credentials = new WebCredentials("Administrator@yourdomain.com", "Password", "yourdomain.com"); service.setCredentials(credentials); service.setUrl(new URI("http://yourserver/EWS/Exchange.asmx")); service.setPreAuthenticate(true);
FindItemsResults<Item> resultMails; mService = new ExchangeService(); mService.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx")); WebProxy paramWebProxy=new WebProxy("ptbproxy.domain.com",8080);
ExchangeService service = new ExchangeService(); EmailMessage msg = null; ExchangeCredentials credentials = null;
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); } }
/** * connect to folder on email server * @param host server address * @param username login for server * @param password password for server * @param email email address we would like to read messages on * @param domain email associated to email address * @throws Exception */ private void connect(String host, String username, String password, String email, String domain, ExchangeVersion version) throws Exception { service = new ExchangeService(version); ExchangeCredentials credentials = new WebCredentials(username, password, domain); service.setCredentials(credentials); service.setUrl(new URI("https://" + host + "/EWS/Exchange.asmx")); // mailbox to use (a mailbox could have several emails mb = new Mailbox(); mb.setAddress(email); rootFolderId = new FolderId(WellKnownFolderName.Root, mb); }
/** * Constructor for instantiating Exchange data source. * * @param settings the settings to use when reading from Microsoft Exchange * @throws Exception if an error occurs */ public ExchangeSourceImpl(final ExchangeSettings settings) throws Exception { LOG.info("Connecting to Exchange (" + settings.getExchangeHost() + ") as " + settings.getExchangeUsername() + "..."); final ExchangeCredentials credentials = new WebCredentials(settings.getExchangeUsername(), settings.getExchangePassword(), settings.getExchangeDomain()); service = new ExchangeService(ExchangeVersion.valueOf(settings.getExchangeVersion())); service.setCredentials(credentials); if (settings.needsExchangeProxy()) { final WebProxy webProxy = new WebProxy(settings.getExchangeProxyHost(), settings.getExchangeProxyPort()); service.setWebProxy(webProxy); } service.setUrl(new URI("https://" + settings.getExchangeHost() + "/EWS/Exchange.asmx")); service.setTraceEnabled(ENABLE_DEBUGGING); LOG.info("Connected to Exchange."); }
protected ExchangeService initializeIfNecessary(ProcessContext context) throws ProcessException { ExchangeVersion ver = ExchangeVersion.valueOf(context.getProperty(EXCHANGE_VERSION).getValue()); ExchangeService service = new ExchangeService(ver); final String timeoutInMillis = String.valueOf(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS)); service.setTimeout(Integer.parseInt(timeoutInMillis)); String userEmail = context.getProperty(USER).evaluateAttributeExpressions().getValue(); String password = context.getProperty(PASSWORD).evaluateAttributeExpressions().getValue(); ExchangeCredentials credentials = new WebCredentials(userEmail, password); service.setCredentials(credentials); Boolean useAutodiscover = context.getProperty(USE_AUTODISCOVER).asBoolean(); if(useAutodiscover){ try { service.autodiscoverUrl(userEmail, new RedirectionUrlCallback()); } catch (Exception e) { throw new ProcessException("Failure setting Autodiscover URL from email address.", e); } } else { String ewsURL = context.getProperty(EWS_URL).getValue(); try { service.setUrl(new URI(ewsURL)); } catch (URISyntaxException e) { throw new ProcessException("Failure setting EWS URL.", e); } } return service; }