简体   繁体   中英

how to get the ipaddress from where each mail is sent in lotus notes

Suppose i have a mail in my lotus notes,Now i have to get from which IP address that mail is sent.How do i get the IP address in domino designer through java.Is there any header information from which i can get the IP Address.

I tried looking in the properties of the document but i could not find anything in there apart from which server i got the mails Please help.

A Notes mail document has an item "Received" which contains information from every server it has passed. You can't find out client's IP address this way (I think that's impossible) but you get the server's IP address at least.

It is not that easy to get ip address from item "Received" though because there are several items "Received" and with document's methods you always get only the last created. As a workaround you have to read item and remove item in a cycle so that you get all items "Received". Here is the Java code for getting the ip address closest to sender:

private String getIPSender(Document doc) {
    String ip = "";
    if (doc != null) {
        try {
            while (doc.hasItem("Received")) {
                Item item = doc.getFirstItem("Received");
                if (item.getValueString().contains("[")) {
                    ip = item.getValueString();
                }
                item.remove();
            }
            if (!ip.isEmpty()) {
                ip = ip.substring(ip.indexOf("[") + 1);
                ip = ip.substring(0, ip.indexOf("]"));
            }
        } catch (Exception e) {
            ip = "";
        }
    }
    return ip;
}

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