Question

I would like to forward emails from my Lotus Notes inbox to my gmail account.

Lotus Notes rules and agents are disabled on our server, so I developed external application for that. I am using document.send method and mail successfully arrives to my gmail box. The only problem is that often the email also duplicated in my Lotus Notes inbox. I just found that the reason of that is "CC" and "BCC" fields, which I don't clean up, however, I am looking for the way to forward email as it is - which means keep original CC and BCC and TO fields - exactly on the same way as it is done by forwarding agent.

I am using "IBM Notes 9" on Windows 7 64 bit.

I've prepared a code sample that demonstrates what I am doing.

package com.example;

import lotus.domino.*;

public class TestMailForwarder {
    public static void main(String[] args) throws NotesException {
        NotesThread.sinitThread();
        try {
            Session notesSession = NotesFactory.createSession(
                    (String) null, (String) null, Consts.NOTES_PASSWORD);
            DbDirectory dir = notesSession.getDbDirectory(Consts.NOTES_SERVER);
            Database mailDb = dir.openDatabaseByReplicaID(Consts.MAILDB_REPLICA_ID);
            forwardAllEmails(mailDb);
        } finally {
            NotesThread.stermThread();
        }
    }

    private static void forwardAllEmails(Database mailDb) throws NotesException {
        View inbox = mailDb.getView("$Inbox");
        //noinspection LoopStatementThatDoesntLoop
        for (Document document = inbox.getFirstDocument(); 
                 null != document; 
                 document = inbox.getNextDocument(document)) {
            document.send(Consts.GMAIL_ADDRESS);
            break;
        }
    }
}
Was it helpful?

Solution 3

Finally, I've found a ready solution: AWESYNC.MAIL. It is a commercial software but it does exactly what I need.

OTHER TIPS

Instead of trying to send the messages to your GMail, why not upload them using Gmail's IMAP interface. You would require to get the message as MIME content - which probably they are already for external incoming eMails and then push them to GMail. I don't have a ready code sample, just one for the opposite pulling GMail into Notes, but you should be able to use that as a starting point.

A code sample for the MIME conversion is in an IBM Technote.

Hope that helps

You can't do a transparent forward with code running at the client level. Pure SMTP systems do it by preserving the RFC-822 header content while altering the RFC-821 RCPT TO data. Domino does not give client-level code independent control over these. It just uses the SendTo, CopyTo, and BlindCopyTo items. (There are some tricks that mail management and archiving vendors play in order to do things like this, but they require special changes to the Domino server's router configuration, and software on the other end as well.

Another way of accomplishing this (in response to the question you asked in your comment) would be to have your Java code make a direct connection to the gmail SMTP servers. I'm not sure how easy it is. A comment on this question states that the Java Mail API allows you to control the RCPT TO separately from the RFC822 headers, but I've not looked into the specifics other than taking note that there's an SMTPTransport class -- which is where I'd look for anything related to RFC-821 protocol. The bigger issue is that you will have to take control of converting messages into MIME format. With Notes mail, you may have a mix of Notes rich text and MIME. Theres a convertToMIME method in Notes 8.5.1 and above, but this will only convert the message body. You'll have to deal with any header content separately. (I'm not really up to speed on Notes 9, but AFAIK even though there is functionality in the client to create a .EML file when you drag a message to the desktop, there's no API there to do that for you.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top