12
12
public class Email extends FolderItem {
13
13
14
14
private Mailbox from ;
15
+ private java .util .HashSet <Mailbox > ToRecipients = new java .util .HashSet <Mailbox >();
16
+ private java .util .HashSet <Mailbox > CcRecipients = new java .util .HashSet <Mailbox >();
17
+ private java .util .HashSet <Mailbox > BccRecipients = new java .util .HashSet <Mailbox >();
18
+
15
19
private String importance = "Normal" ;
16
20
private String sensitivity = "Normal" ;
17
21
private Integer size ;
18
22
private boolean isRead = false ;
19
- private java .util .HashSet <Mailbox > ToRecipients = new java .util .HashSet <Mailbox >();
20
- private java .util .HashSet <Mailbox > CcRecipients = new java .util .HashSet <Mailbox >();
21
- private java .util .HashSet <Mailbox > BccRecipients = new java .util .HashSet <Mailbox >();
23
+ private javaxt .utils .Date sent ;
24
+ private javaxt .utils .Date received ;
25
+ private String response ;
26
+ private javaxt .utils .Date responseDate ;
27
+
28
+ //The following parameters are for internal use only!
22
29
private String referenceId ;
23
30
private String messageType = "Message" ;
24
31
@@ -59,13 +66,17 @@ private void init(javaxt.exchange.Email message){
59
66
60
67
//Email specific information
61
68
this .from = message .from ;
69
+ this .ToRecipients = message .ToRecipients ;
70
+ this .CcRecipients = message .CcRecipients ;
71
+ this .BccRecipients = message .BccRecipients ;
62
72
this .importance = message .importance ;
63
73
this .sensitivity = message .sensitivity ;
64
74
this .size = message .size ;
65
75
this .isRead = message .isRead ;
66
- this .ToRecipients = message .ToRecipients ;
67
- this .CcRecipients = message .CcRecipients ;
68
- this .BccRecipients = message .BccRecipients ;
76
+ this .sent = message .sent ;
77
+ this .received = message .received ;
78
+ this .response = message .response ;
79
+ this .responseDate = message .responseDate ;
69
80
this .referenceId = message .referenceId ;
70
81
this .messageType = message .messageType ;
71
82
}
@@ -88,7 +99,7 @@ protected Email(org.w3c.dom.Node messageNode) {
88
99
//**************************************************************************
89
100
/** Creates a new instance of this class
90
101
*/
91
- public Email (String exchangeID , Connection conn , ExtendedProperty [] AdditionalProperties ) throws ExchangeException {
102
+ public Email (String exchangeID , Connection conn , ExtendedFieldURI [] AdditionalProperties ) throws ExchangeException {
92
103
super (exchangeID , conn , AdditionalProperties );
93
104
parseMessage ();
94
105
}
@@ -110,6 +121,9 @@ public Email(String exchangeID, Connection conn) throws ExchangeException{
110
121
/** Used to parse an xml node with email information.
111
122
*/
112
123
private void parseMessage (){
124
+
125
+ boolean isDraft = false ;
126
+
113
127
org .w3c .dom .NodeList outerNodes = this .getChildNodes ();
114
128
for (int i =0 ; i <outerNodes .getLength (); i ++){
115
129
org .w3c .dom .Node outerNode = outerNodes .item (i );
@@ -169,6 +183,51 @@ else if(nodeName.equalsIgnoreCase("BccRecipients")){
169
183
else if (nodeName .equalsIgnoreCase ("IsRead" )){
170
184
isRead = javaxt .xml .DOM .getNodeValue (outerNode ).equalsIgnoreCase ("true" );
171
185
}
186
+ else if (nodeName .equalsIgnoreCase ("IsDraft" )){
187
+ isDraft = javaxt .xml .DOM .getNodeValue (outerNode ).equalsIgnoreCase ("true" );
188
+ }
189
+ else if (nodeName .equalsIgnoreCase ("DateTimeSent" )){
190
+ try {
191
+ sent = new javaxt .utils .Date (javaxt .xml .DOM .getNodeValue (outerNode ));
192
+ }
193
+ catch (java .text .ParseException e ){}
194
+ }
195
+ else if (nodeName .equalsIgnoreCase ("DateTimeReceived" )){
196
+ try {
197
+ received = new javaxt .utils .Date (javaxt .xml .DOM .getNodeValue (outerNode ));
198
+ }
199
+ catch (java .text .ParseException e ){}
200
+ }
201
+ }
202
+ }
203
+
204
+ //Update the sent and received timestamps as needed
205
+ if (isDraft ) sent = received = null ;
206
+
207
+
208
+ //Find the PR_LAST_VERB_EXECUTED (0x10810003) extended MAPI property
209
+ java .util .Iterator <ExtendedFieldURI > it = extendedProperties .keySet ().iterator ();
210
+ while (it .hasNext ()){
211
+ ExtendedFieldURI property = it .next ();
212
+ if (property .getName ().equalsIgnoreCase ("0x1081" )){
213
+ Integer value = extendedProperties .get (property ).toInteger ();
214
+ if (value ==102 ) this .response = "Reply" ;
215
+ else if (value == 103 ) this .response = "ReplyAll" ;
216
+ else if (value == 104 ) this .response = "Forward" ;
217
+ extendedProperties .remove (property );
218
+ break ;
219
+ }
220
+ }
221
+
222
+
223
+ //Find the PR_LAST_VERB_EXECUTION_TIME (0x10820040) extended MAPI property
224
+ it = extendedProperties .keySet ().iterator ();
225
+ while (it .hasNext ()){
226
+ ExtendedFieldURI property = it .next ();
227
+ if (property .getName ().equalsIgnoreCase ("0x1082" )){
228
+ responseDate = extendedProperties .get (property ).toDate ();
229
+ extendedProperties .remove (property );
230
+ break ;
172
231
}
173
232
}
174
233
}
@@ -304,19 +363,25 @@ public Mailbox getFrom(){
304
363
305
364
306
365
//**************************************************************************
307
- //** setFrom
366
+ //** getDateTimeReceived
308
367
//**************************************************************************
309
- /** Used to set the sender.
310
- *
311
- public void setFrom(Mailbox from){
368
+ /** Returns the date/time when the message was received. Returns a null if
369
+ * the message is a draft.
370
+ */
371
+ public javaxt .utils .Date getDateTimeReceived (){
372
+ return received ;
373
+ }
312
374
313
- if (id!=null) {
314
- if (from==null && this.from!=null) updates.put("From", null);
315
- if (from!=null && !from.equals(this.from)) updates.put("From", from.toXML("t"));
316
- }
317
- this.from = from;
375
+
376
+ //**************************************************************************
377
+ //** getDateTimeSent
378
+ //**************************************************************************
379
+ /** Returns the date/time when the message was sent. Returns a null if
380
+ * the message has not been sent (e.g. Draft message).
381
+ */
382
+ public javaxt .utils .Date getDateTimeSent (){
383
+ return sent ;
318
384
}
319
- */
320
385
321
386
322
387
//**************************************************************************
@@ -329,6 +394,30 @@ public Integer getSize(){
329
394
}
330
395
331
396
397
+ //**************************************************************************
398
+ //** getResponse
399
+ //**************************************************************************
400
+ /** Returns the last action performed on this message. Possible values
401
+ * include "Forward", "Reply", "ReplyAll", or null.
402
+ */
403
+ public String getResponse (){
404
+ return response ;
405
+ }
406
+
407
+
408
+ //**************************************************************************
409
+ //** getResponseDate
410
+ //**************************************************************************
411
+ /** Returns the date/time associated with the last action performed on this
412
+ * message. This, in conjunction with the getResponse() method can be used
413
+ * to generate messages like "You replied on 12/13/2012 5:38 PM." or
414
+ * "You forwarded this message on 12/13/2012 6:01 PM."
415
+ */
416
+ public javaxt .utils .Date getResponseDate (){
417
+ return responseDate ;
418
+ }
419
+
420
+
332
421
//**************************************************************************
333
422
//** isRead
334
423
//**************************************************************************
0 commit comments