ffdream62 Posted August 10, 2011 Posted August 10, 2011 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
water Posted August 10, 2011 Posted August 10, 2011 (edited) 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 August 10, 2011 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
ffdream62 Posted August 11, 2011 Author Posted August 11, 2011 Hi Water, Thanks for the links, I'll have a look and start playing with this. Sorry for wrong posting...
ffdream62 Posted August 11, 2011 Author Posted August 11, 2011 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. expandcollapse popup;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 ?
ffdream62 Posted August 12, 2011 Author Posted August 12, 2011 I finaly left it... I'm saving attachment by VBA though an Access Db.
ffdream62 Posted September 13, 2011 Author Posted September 13, 2011 (edited) 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 September 13, 2011 by ffdream62
water Posted September 13, 2011 Posted September 13, 2011 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 2024-07-28 - Version 1.6.3.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 (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
ffdream62 Posted September 13, 2011 Author Posted September 13, 2011 (edited) 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 September 13, 2011 by ffdream62
water Posted September 13, 2011 Posted September 13, 2011 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 2024-07-28 - Version 1.6.3.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 (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
ffdream62 Posted September 13, 2011 Author Posted September 13, 2011 Are you talking about the code from the first post ?
water Posted September 13, 2011 Posted September 13, 2011 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 2024-07-28 - Version 1.6.3.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 (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
ffdream62 Posted September 13, 2011 Author Posted September 13, 2011 (edited) 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 September 13, 2011 by ffdream62
water Posted September 13, 2011 Posted September 13, 2011 Replace if $m_rt.Type = RICHTEXTwithif $m_rt.Type = 1according to the original VB code. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
willichan Posted September 13, 2011 Posted September 13, 2011 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. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash
ffdream62 Posted September 14, 2011 Author Posted September 14, 2011 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")
water Posted September 14, 2011 Posted September 14, 2011 $m_rt.embeddedObjects returns an array. So replace ConsoleWrite with _ArrayDisplay($m_rt) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
ffdream62 Posted October 4, 2011 Author Posted October 4, 2011 Not crashing... but not showing any array ! Any other idea ?
water Posted October 4, 2011 Posted October 4, 2011 Can you post the relevant parts of the code? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now