我正在使用 java HttpClient 4.x 为 Outlook 连接器创建一个库。我必须从我的应用程序发送邮件。我可以将消息放在草稿文件夹中。但我怎样才能发送给收件人。这是我尝试过的代码`
String strTempURI = "https://" + serverName + "/exchange/" + Username
+ "/drafts/" +strSubject + "eml";
String strSubURI = "https://" + serverName + "/exchange/" + Username
+ "/##DavMailSubmissionURI##/";
URI uri=new URI(strTempURI);
HttpPut put = new HttpPut(uri);
ByteArrayEntity entity = new ByteArrayEntity(byteout1);
DefaultHttpClient client =new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST,
AuthScope.ANY_PORT,AuthScope.ANY_REALM, AuthPolicy.BASIC),
new UsernamePasswordCredentials(Username, password));
client.setCredentialsProvider(credsProvider);
put.setHeader("Content-Type", "message/rfc822");
put.setEntity(entity);
localContext.setAttribute(ClientContext.CREDS_PROVIDER, credsProvider);
HttpResponse response=client.execute(put,localContext);
HttpEntity resEntity = response.getEntity();
String result = EntityUtils.toString(resEntity);
“byteout1”包含邮件内容。在 client.execute() 之后,我想将内容移动到“strSubURI”