1 packagecom.fzw.exchangeClient;2
3 importjava.net.URI;4 importjava.net.URISyntaxException;5 importjava.util.ArrayList;6 importjava.util.Arrays;7 importjava.util.List;8
9 importlombok.extern.slf4j.Slf4j;10 importmicrosoft.exchange.webservices.data.core.ExchangeService;11 importmicrosoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;12 importmicrosoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;13 importmicrosoft.exchange.webservices.data.core.service.item.EmailMessage;14 importmicrosoft.exchange.webservices.data.credential.ExchangeCredentials;15 importmicrosoft.exchange.webservices.data.credential.WebCredentials;16 importmicrosoft.exchange.webservices.data.property.complex.MessageBody;17
18 @Slf4j19 public classExchangeClient {20
21
22 private finalString hostname;23 private finalExchangeVersion exchangeVersion;24 private finalString domain;25 private finalString username;26 private finalString password;27 private finalString subject;28 private finalString recipientTo;29 private final ListrecipientCc;30 private final ListrecipientBcc;31 private final Listattachments;32 private finalString message;33
34 privateExchangeClient(ExchangeClientBuilder builder) {35 this.hostname =builder.hostname;36 this.exchangeVersion =builder.exchangeVersion;37 this.domain =builder.domain;38 this.username =builder.username;39 this.password =builder.password;40 this.subject =builder.subject;41 this.recipientTo =builder.recipientTo;42 this.recipientCc =builder.recipientCc;43 this.recipientBcc =builder.recipientBcc;44 this.attachments =builder.attachments;45 this.message =builder.message;46 }47
48 public static classExchangeClientBuilder {49
50 privateString hostname;51 privateExchangeVersion exchangeVersion;52 privateString domain;53 privateString username;54 privateString password;55 privateString subject;56 privateString recipientTo;57 private ListrecipientCc;58 private ListrecipientBcc;59 private Listattachments;60 privateString message;61
62 publicExchangeClientBuilder() {63 this.exchangeVersion =ExchangeVersion.Exchange2010_SP1;64 this.hostname = "";65