Jump to content

LOTUS NOTES - Save attachment


Recommended Posts

Hi everybody,

A server is sending me CSV files via email every 2 hours on a Lotus Notes email address.

I try to find a way to pick the attachment from each email, rename it, and save it in a local folder.

Unfortunatly, I can't find anything in the help/web and I don't have any way to start.

Did anyone already manage to handle Notes though AutoIt ?

Thx

Link to comment
Share on other sites

Hi ffdream62,

welcome to AutoIt and the forum!

Some notes from my side:

  • You are posting on the wrong forum. "Example Scripts" is for users to post their example scripts so everyone can use them. General questions should be posted in "General Help and Support".
  • To access Lotus Notes you could use the COM interface. Google for "receive mail lotus notes visual basic" and you will find a lot of solutions. Something like this (written in german) or this (even better).
Good luck! Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I started working on it but still not managed to extract anything.

"Extractfile" property is used in all VB codes I saw but it's not working when I try it though Autoit.

Here is the code I started to extract attachment of the first email from the Lotus Notes Inbox.

;Initialize Lotus Notes
$Session = ObjCreate("Notes.NotesSession")
$Maildb = $Session.GetDatabase ("", "")

If Not $Maildb.IsOpen  Then
    $Maildb.OPENMAIL
EndIf

;Look for the first mail in the Lotus Notes "Inbox"
$ntView = $Maildb.GETVIEW ("($Inbox)")
$ntNavigator = $ntView.CREATEVIEWNAV ()
$ntViewEntry = $ntNavigator.GETFIRSTDOCUMENT ()
        
$ntDocument = $ntViewEntry.Document

;Give the mail subject  
$Subject = $ntDocument.GETFIRSTITEM ("subject")
ConsoleWrite("Sujet Mail : " & $Subject.Text & ", ")

;Give the mail date & time  
$PostedDate = $ntDocument.GETFIRSTITEM ("PostedDate")
ConsoleWrite("Date: " & $PostedDate.Text & ", ")
    
;Check if an attached is available

    If $ntDocument.HasEmbedded Then 

        ConsoleWrite("Attached found" & @CrLf)  

        ;**********HERE IT'S BLOCKING - I can't get the attached
        $vaAttachment = $ntDocument.GetAttachment()
        $vaAttachment.extractfile("c:\" & $vaAttachment.name)

    Else

        ConsoleWrite("Attached not found" & @CrLf)

    endif

Can U help me ?

Link to comment
Share on other sites

  • 1 month later...

Hi !

I restarted working on this code, I found something better but still not manage to do what I want to do !

The following part of the code returns me an error (The requested action with this object has failed)

$vaAttachment = $ntDocument.GetAttachment()

But if I add the attachment name into the brackets, I'm able to handle it.

$vaAttachment = $ntDocument.GetAttachment("MyFile.csv")

So I did some tests with the following but nothing working.

$vaAttachment = $ntDocument.GetAttachment("*")
$vaAttachment = $ntDocument.GetAttachment("*.*")
$vaAttachment = $ntDocument.GetAttachment(*)
$vaAttachment = $ntDocument.GetAttachment(*.*)

Any other idea ?

Edited by ffdream62
Link to comment
Share on other sites

What I have found on the web states that the GetAttachment method needs the name of an attachement as first parameter.

What you need is a way to list all attachments of a Notes document.

Here I found an example that you need to translate to AutoIt.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I don't find the way to translate it...

Is it something like that ?

$Attachment = $ViewEntry.evaluate("@AttachmentNames", $Document)

or

$Attachment = $Document.evaluate("@AttachmentNames", $Document)

I also test the following which returned "Unknown macro" error message :

$Attachment = $document.evaluate(@AttachmentNames)
Edited by ffdream62
Link to comment
Share on other sites

Seems to be a function of LotusScript. I fear you'll have to translate the first solution to AutoIt.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The link in my last post conained two solutions. One was the "Evaluate" version the other was afew lines above.

m_Doc = m_View.GetFirstDocument()
Do Until m_Doc is nothing
if (m_Doc.hasItem("body")) then
    m_rt = m_Doc.GetFirstItem("Body")
        if (m_rt.Type = RICHTEXT) then   ' RICHTEXT=1
            m_objects = m_rt.embeddedObjects
            ... ' same as earlier code to extract attachments
        end if
    end if
end if

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I still don't manage to translate it.

I think I can't test the "richtext" type.

I first try to do it for first email of the list with following code.

$m_Doc = $View.GetFirstDocument()
if $m_Doc.hasItem("body") then
       $m_rt = $m_Doc.GetFirstItem("Body")
       if $m_rt.Type = RICHTEXT then
            $m_objects = $m_rt.embeddedObjects
            Msgbox(0,"","I've got it")
       endif
endif
Edited by ffdream62
Link to comment
Share on other sites

Replace

if $m_rt.Type = RICHTEXT
with
if $m_rt.Type = 1
according to the original VB code.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You might also try creating a Lotus Agent that will run a Lotus Script. I don't get in depth on Notes, but it looks like a script was provided, and method for kicking it off here.

Link to comment
Share on other sites

Thank Water for the translation of RICHTEXT ! Code is well running but I'm still in trouble to extract files or return their names.

Here's my code :

$m_Doc = $View.GetFirstDocument()
if $m_Doc.hasItem("body") then
      $m_rt = $m_Doc.GetFirstItem("Body")
      if $m_rt.Type = 1 then
           $m_objects = $m_rt.embeddedObjects
           Msgbox(0,"","I've got it")                                                         ;****** here it's OK
           ConsoleWrite("Attachment : " & $m_objects.name & @Crlf)       ;****** here it's not
      endif
endif

I also tried to show it as an array but nothing in.

I try to do the extract directly on the "$m_objects" but not working too (Error : Variable must be of type "Object")

Link to comment
Share on other sites

$m_rt.embeddedObjects returns an array. So replace ConsoleWrite with _ArrayDisplay($m_rt)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 3 weeks later...

Can you post the relevant parts of the code?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...