« Secrets of the E-Mail Maven: Don't Just Delete Your E-mail ! Use the “Magic” Folder ! | Main| Microsoft-Yahoo Might Also Be About Mail »

Adjusting for the Domino IMAP INTERNALDATE value

Category IBM/Lotus Domino
Summary: Domino does not return the correct IMAP time value, but there is a work-around.

For several years our company has relied on the processing of customer submissions for advertising content, billing and graphics through a non-Domino e-mail server. The e-mail would contain an attachment, which was stripped out and prepared by another server process. Well, the receiving mail server has given up the ghost, and now all of this in-bound is being funneled through our Domino mail servers.

We didn't foresee any problems, as converting a Domino mail file to become IMAP capable is quite straightforward. But, we did have one, very sticky, problem: the received date/time value was wrong. The previous IMAP server would ensure that the INTERNALDATE MIME header contained the time/date value for the receiving server's timezone (TZ).

We are in EST, and the Domino MIME header for INTERNALDATE would only return the GMT result. The C++ programmer responsible for parsing out the IMAP entries, with their attachments, was not happy. If we couldn't find a fix, then he would have to create and maintain code for adjusting the INTERNALDATE from GMT and accounting for Daylight Savings Time. We've all been through enough DST changes to feel sympathy for his reluctance.

Maybe, I thought, there is some notes.ini configuration setting which would set the IMAP time value? After two weeks with IBM, we received the final word: Domino leaves it up the IMAP client to make the TZ adjustment. This does kind've make sense. After all, if I have two IMAP clients from different TZs going against the same server, then their received time needs to be specific to the client location. Maybe IBM's default setting isn't so wrong, after all; it just doesn't help me, or the C++ programmer.

My solution was to create a BeforeNewMail agent to extend the MIME with a new header that contained the time/date value in just the format as with the prior system. While I would prefer not having to run an agent against in-bound e-mail, I think this is a worthy exception to the rule.

I've included the code, and left in the collection loop (which I use for testing against selected documents). Not all admins are programmers, so there are few things to be aware of before making customizations. A BeforeNewMail agent is run by the Domino Router task, so you won't see it registered by the Agent Manager. It should also be bullet-proof and as streamlined as possible. Choking the Router with erroneous code is going to create a big mess, very quickly.

Finally, you need to know that a BeforeNewMail agent runs in its own bubble, and can't do database lookups or work with environment values. It has a handle on the NotesSession.DocumentContext, and whatever has been hardcoded.--that's all there is to work with on the document.

The actual solution did not turn out to be complicated or difficult. But, I thought I would spare someone else the effort taken to resolve the IMAP values.



'BeforeNewMailProcessing:

Option Public
Option Declare
'This BeforeNewMail agent transfers the in-bound message into the
'GetIt InBox folder and then adds a MIME header to the entity for
'a DST adjusted time value.
'
'The date structure needs to be formatted as TWP_DATE 30-Jan-2008 16:05:55 +0000

Sub Initialize
    Dim s As New NotesSession
    Dim doc As NotesDocument
    Dim mime As NotesMIMEEntity
   
    Dim copy As NotesDocument
    Dim db As NotesDatabase
   
    Dim body As NotesMIMEEntity
    Dim header As NotesMIMEHeader
    Dim headerstring As String
   
    Dim currentTime As NotesDateTime
   
    s.ConvertMime = False
    Set db = s.CurrentDatabase   
    Set currentTime = New NotesDateTime( "Today" )
    currentTime.LSLocalTime = Now 'Set time to now
   
%REM
    '------------------------------------
    'this is only in place for development as it will work with selected documents in a view
    'after the results are verified as correct, then comment it out,
     'change the agent properties to BeforeNewMail and use the session.documentcontext
   
    Dim selecteddoccoll As NotesDocumentCollection
    Set selecteddoccoll = db.UnprocessedDocuments
   
    Set doc = selecteddoccoll.GetFirstDocument   
    While Not (doc Is Nothing)
       
        Set doc = selecteddoccoll.GetNextDocument(doc)
    Wend
    '------------------------------------
%END REM
   
    Set doc = s.DocumentContext 'pick up the inbound email from a BeforeNewMail agent
   
    headerstring = Format$(doc.delivereddate(0),"dd-mmm-yyyy") & { } & Format$(doc.delivereddate(0),"hh:mm:ss") & { -0} & currentTime.TimeZone & {00}
   
    Set body = doc.GetMIMEEntity
   
    Set header = body.CreateHeader("X-TWP_DATE")
    Call header.SetHeaderVal(headerstring)
   
    Call doc.Save(True, True)
    Call doc.PutInFolder("GetIt InBox", True) 'move to the  folder   
    s.ConvertMIME = True ' Restore conversion
   
End Sub


Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)