Jump to content
Sign in to follow this  
ffdream62

LOTUS NOTES - Save attachment

Recommended Posts

ffdream62

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

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
ffdream62

Hi Water,

Thanks for the links, I'll have a look and start playing with this.

Sorry for wrong posting...

Share this post


Link to post
Share on other sites
ffdream62

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 ?

Share this post


Link to post
Share on other sites
ffdream62

I finaly left it... I'm saving attachment by VBA though an Access Db.

Share this post


Link to post
Share on other sites
ffdream62

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

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
ffdream62

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

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
ffdream62

Are you talking about the code from the first post ?

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
ffdream62

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

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
willichan

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.

Share this post


Link to post
Share on other sites
ffdream62

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")

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
ffdream62

Not crashing... but not showing any array !

Any other idea ?

Share this post


Link to post
Share on other sites
water

Can you post the relevant parts of the code?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

×