2
votes

I am working on an integration where I have to extract lotus email documents on regular intervals of 2 min. I have created a PowerShell script to connect to local notes client. I am successful to read the latest document but I am unable to put a time filter to get last 5 min email from notes database. I also tried to get documents which are not yet read by the lotus notes ID which I used to connect to a lotus notes database.

This is for a new integration to retrieve past 5 min documents or documents which are not read by the current lotus notes ID used inside Powershell script. I was able to get only the latest document but when I applied the time filter it gives me values which are not matching the real values when I checked inside lotus notes.

$DomSession = New-Object -ComObject Lotus.NotesSession
$DomSession.Initialize()
$DomDatabase = $DomSession.GetDatabase("DominoServer","email.nsf")
Write-Host "Database open : " $DomDatabase.Title
$DomView = $DomDatabase.GetView('All By Category')
Write-Host "View read : " $DomView.Name
$DomNumOfDocs = $DomView.AllEntries.Count
Write-Host "Num of Docs : " $DomNumOfDocs
$DomDoc = $DomView.GetFirstDocument()
$DomDoc.ColumnValues #This gives the latest email document
Do {
    $checks = $DomDoc.Items
    foreach ($check in $checks) {
        if ($check.Name -eq 'Subject') {
            [pscustomobject]@{
            subject = $check.Text
            creationtime = $check.LastModified
            }
        }
    }
    $DomDoc = $DomView.GetNextDocument($DomDoc)
   }
while ($DomDoc.LastModified -gt ((get-date).AddMinutes(-5)))

I expect to get email documents created for the past 5 min or so, but I get all documents inside the notes database.

1
I've no clue of Lotus ComObject, but I'd try $searchDate = (Get-Date).AddMinutes(-5)user6811411
I tried it but it did not work. I did a modification to the code to get the last 5 min document list but it is giving me 30 min data. I could not understand how the time value is processed by Lotus notes com object. Modified code added to the question.Naresh Kumar Gnanakrishnan
Do you have to use PowerShell? I expect you know that Notes is programmable, and that you can develop agents in it for lots of different purposes. There may be other standard features that you could use, e.g. Mail Journaling. What exactly is your project, what do you want to integrate?D.Bugger

1 Answers

0
votes

Found a way to get emails from Lotus notes database using notes commands. Below script will get emails received in the past 15 min.

$DomSession = New-Object -ComObject Lotus.NotesSession
$DomSession.Initialize()
$DomDatabase = $DomSession.GetDatabase("DominoSERVER", "MAIL.nsf")
Write-Host "Database open : " $DomDatabase.Title
$DomView = $DomDatabase.GetView('All By Category')
Write-Host "View read : " $DomView.Name
$DomNumOfDocs = $DomView.AllEntries.Count
Write-Host "Num of Docs : " $DomNumOfDocs
$DomDoc = $DomView.GetFirstDocument()
#$DomDoc.ColumnValues
Do {
       $checks = $DomDoc.Items
        foreach ($check in $checks) {
            if ($check.Name -eq 'Subject') {
                [pscustomobject]@{
                subject = $check.Text
                creationtime = $check.LastModified
                }
            }
        }
        $DomDoc = $DomView.GetNextDocument($DomDoc)
   }
while ($check.LastModified -gt ((get-date).AddMinutes(-15)))

Now I have to make sure that the script runs every 15 min to get all emails raised for the past 15 min. I am still looking to mark email which is already picked by above script, If I can crack that I will share the solution as well or if someone already did it please do share or improve the script.

Happy Coding everyone!!!