我有一个要求。我需要访问公司特定域中用户的电子邮件。我需要获取该用户的日历并将其发布到Web应用程序。我筋疲力尽,找不到任何可以帮助我做到这一点的API。公司使用的电子邮件客户端是Thunder Bird,因此,具体来说,我需要为该特定用户访问Thunder Bird的日历。谁能告诉我一些建议。
I have a requirement. I need to access a user's email that is on company specific domain. I need to get the calendar of that user and publish it to web application. I am exhausted finding any API that can help me to do that. The email client used by company is Thunder Bird, So , in specific, I need to access calender's from Thunder Bird for that particular user. Can any one tell me some suggestions for this.
推荐答案库马尔
您的问题非常不精确(提供电子邮件/日历的服务器是哪种类型?是否有LDAP域?等等)。我想您是由于某些域和WebDAV以及搜索时遇到的问题而谈论的是旧版Exchange Server?但是我也许可以至少给您一些帮助,这可能会导致您进入其他编码人员已经不熟悉的路径,以便您可以找到简单快捷的解决方案。
Your question is very unprecise (what kind of is the server providing the emails/calendars? Is there a LDAP Domain? And so on). I suppose you are talking about an old Exchange Server because of some Domain and WebDAV and problems while searching? But I maybe can give you at least a bit of help, that may lead you to already trodden paths of other coders, so that you may find a simple and fast solution.
今天,我完成了M $ Exchange 2003连接器作为概念验证。我告诉你,作为实习生,对我来说真的很难。尽管如此,我还是进行了研究,搜索和查询,并惹恼了其他人,以获取有用的API的提示,但没有一个达到我的目的。
Today I finished a M$ Exchange 2003 Connector as a proof-of-concept. And I tell you, that it was really hard for me as a student while an Internship. Nonetheless, I researched and searched and queried and annoyed other to get hints for a useful API, but none fulfilled my purposes.
我发现一个很好用的小框架被称为 Sardine WebDAV Client for Java 。该项目的重量很轻,尽管有助于您了解WebDAV的工作原理,即使由于您总是可以查看资源而有所帮助。
One small framework I found which is nice to use is called Sardine WebDAV Client for Java. The project is very light-weighted, though it was helpful to get an idea how WebDAV works, even due to sources you can always look at.
所有其他解决方案都针对Linux的许多不同的MAPI CC ++库。对我来说这是没有选择的。
All other solutions aimed at a lot of different MAPI CC++ Libs for Linux. That was no option for me.
那么,我有什么选择?没有直接访问客户Exchange 2k3服务器的权限,只有一个电子邮件帐户。所以你们大家都可以原谅我,但是我发现通过OWA向E2k3服务器发出POST请求要容易得多,因为它比尝试一些受lib支持的重型访问方式更容易激活。
So, what options did I have? No direct access to the customers Exchange 2k3 Server, but one email account. So you all may forgive me, but I found it much easier to make a POST request to the E2k3 Server via OWA, because it was activated than trying some heavy lib supported ways of accessing.
也许这很有用-从OWA表单获取表单字段信息,并构建一个发布到服务器的连接字符串。也许这是一个字符串,可能会给您一个想法。因此,您需要像这样调用DLL:
Maybe this comes to your avail- Get the form-field information from the OWA form and build a connection string you Post to the server. Perhaps this is a string that might give you an idea. So you need to call a DLL like this:
HttpPost httpPost = new HttpPost("" + getUrl() + "/exchweb/bin/auth/owaauth.dll"); httpPost.setEntity(new StringEntity("destination=https%3A%2F%2F" + getUrl() + "%2Fexchange%2F&flags=0&username=" + getUser() + "&password=" + getPassword() + "&SubmitCreds=Log+On&trusted=4&flags=4", "UTF-8"));如何进行基于表单的身份验证的信息来自以下位置:基于Exchange 2003基于表单的身份验证。如您所见,我从浏览器中获取了Link,该Link用于与E2k进行通信。下一步很简单-发送请求并等待...
The information how to make a form based authentication came from here: Exchange 2003 Forms-Based Authentication. As you can see I grabbed from the browser the Link, which is used to communicate with the E2k. The next step is simple - send the request and wait for...
HttpResponse response = httpclient.execute(httpPost);如果得到良好的回应,则可以过滤出会话ID。成功登录后的下一步是搜索约会。因此,通过向M $询问一些信息,您应该找到一种适用于建立的WebDAV连接的适当方法:搜索方法
If you get a good response in return, then you can filter out the Session ID. The next step after a successful login is to search for appointments. Therefore you should find a appropriate method to work with on an established WebDAV connection by asking M$ for some Information: SEARCH Method
然后,您将阅读它的功能。我继续使用著名的Find-Machine,并查询了使用以下方法搜索日历文件夹WebDAV 。
Then, you read what it can do. I went on with a well-known Find-Machine and queried for Searching Calendar Folders with WebDAV.
之后,您可以创建这样的POST请求:
After that you can create a POST request like this:
HttpPost hp = new HttpPost( "owa.SERVER.de/exchange/USER/Calendar") { @Override public String getMethod() { return "SEARCH"; } };现在,您可以使用SEARCH方法了。很好,因为您的程序已准备好发送请求。
Now you can make use of the SEARCH method. That is good, because your program is ready to send the request.
hp.setEntity(new StringEntity(QUERY, ContentType.TEXT_XML)); HttpResponse response = httpclient2.execute(hp);我知道这不是完美的解决方案。因为有两种情况使我感到奇怪。首先:我检索了一个会话ID,但是只要将其保存在字段中,就不需要在任何地方重复使用它。其次:我需要调用另一个HttpClient。我现在无法解释。如果我使用与登录相同的HttpClient,那么所有请求都是徒劳的。这就是为什么我必须调用另一个HttpClient的原因。
I know it is no perfect solution. Because there were two circumstances which made me wonder. Firstly: I retrieved a Session ID, but I wasn't in need to re-use it anywhere, as long as I kept it in a field. And secondly: I needed to call for another HttpClient. I cannot explain right now. If I used the same HttpClient I used for logon, then all request were in vain. That is why I had to call another HttpClient.
最后也是最困难的一步是查询背后的问题,因为我仅有的调试帮助是HTTP错误号和MSDN中的错误描述。抱歉好吧,这确实很好。我在Trial and Error后面获得支持。
The last and most difficult step was to get behind the query, because the only debugging help I had were HTTP Error Numbers and the bad descriptions in the MSDN. Sorry for that. Well, this is what really worked fine. I got behind it with Trial and Error.
private final static String QUERY = "<?xml version=\"1.0\"?><g:searchrequest xmlns:g=\"DAV:\"><g:sql> Select \"DAV:href\", \"urn:schemas:calendar:dtstart\", \"urn:schemas:calendar:dtend\", \"urn:schemas:mailheader:subject\", \"urn:schemas:calendar:duration\" FROM Scope('SHALLOW TRAVERSAL OF \"/exchange/USER/Calendar\"')</g:sql></g:searchrequest>";这不是特定查询。我只是从另一个文档中替换了它,并删除了我不需要的所有内容。
This is no particular query. I just alternated it from another Document and removed all stuff I didnt't need.
我希望这对您有所帮助。关于提供雷鸟约会/日历日期,我什么也不能说,因为这还不知道。
I hope this helps you a bit. About providing Thunderbird Appointment/Calendar dates I can't tell anything because this is yet beyond my knowledge.
最诚挚的问候和晚安,
Semo
更多推荐
使用Java访问用户电子邮件地址的日历
发布评论