简体   繁体   中英

Lotus Notes - Mail Document - Principal/From,INetFrom, SentTime, ReceivedTime fields

I have a requirement to fetch the SenderName,SenderEmail,ToNames,ToEmails,CCNames,CcEmails from a lotus notes document instance.

Issue1 Looking into lotus.domino.Document API I found out the method getItems. When I write the elements to the system.out values for SenderEmail, ToEmails and CcEmails can be found.

However values for SenderName(aka From), ToNames cannot be derived that easily.

The values seems to be using an common name format. For example check check my system.output below.

Principal = "CN=Amaw Scritz/O=fictive"
$MessageID = "<OF0FF3779B.36590F8A-ON80257D15.001DBC47-65257D15.001DC804@LocalDomain>"
INetFrom = "AmawScritz@fictive.com"
Recipients = "CN=Girl1/O=fictive@fictive"
MailOptions = "0"
SaveOptions = "1"   
From = "CN=Amaw Scritz/O=fictive"
AltFrom = "CN=Amaw Scritz/O=fictive"    
SendTo = "CN=Girl1/O=fictive@fictive"
CopyTo = "CN=Girl2/O=fictive@fictive"
BlindCopyTo = ""
InetSendTo = "Girl1@fictive.com"
InetCopyTo = "Girl2@fictive.com"    
$Abstract = "sasdasda"  
$UpdatedBy = "CN=Amaw Scritz/O=fictive" 
Body = "Hello World"

The question is how can I get 'Amaw Scritz' from the common name 'CN=Amaw Scritz/O=fictive'. Is there any look up mechanism that can be used. (I would prefer to have a option other than doing a substring of the common name)

Issue2 is it possible to retrieve SentTime and ReceivedTime from mail document instance? I know that there are two methods called getCreated and getLastModified. getCreated can be loosely associated with the SentTime and getLastModified can be loosely associated with ReceivedTime. Are there are other ways to get times for SentTime and ReceivedTime.

Issue3 How can one distinguish whether a mail document is a Sent mail or a Received Mail?

Issue1
You can use Name class.
Here example from this link :

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 

      // Create a hierarchical name
      Name nam = session.createName(
        "CN=John B Goode/OU=Sales/OU=East/O=Acme/C=US");

      // Returns:
      // John B Goode
      // John B Goode/Sales/East/Acme/US
      // CN=John B Goode/OU=Sales/OU=East/O=Acme/C=US
      System.out.println(nam.getCommon());
      System.out.println(nam.getAbbreviated());
      System.out.println(nam.getCanonical());

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}

Issue2
Use values of PostedDate field and DeliveredDate field of mail document.

Issue3
Check that $Inbox folder contains your mail document. Or take a look at Dave Delay answer .

I agree with @nempoBu4 on Issues 1 and 2. I disagree with the answer to Issue 3. A received message can be removed from the inbox, so checking $Inbox doesn't help you distinguish between sent and received messages.

Assuming you have the document open, the best approach is to check two items. Sent and received messages both have a PostedDate item, but only a received message has a DeliveredDate item. Incidentally, a draft message has neither PostedDate or DeliveredDate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM