Download all attachments in a Lotus Notes folder & save to desktop folder

bcurrey

Board Regular
Joined
Aug 11, 2011
Messages
110
Office Version
  1. 365
Platform
  1. MacOS
I couldn't find anything on this. I have about 20 reports emailed to me throughout the night. Each come in separate emails and go to a designated folder based on mail rules I have set up in LN.

Each day, I have to go into each email and save the reports to my hard drive. Then go through and look at certain numbers in each report.

Is there a way for me to run a macro that will go download all attachments in a specified folder with lotus notes and then save them to a folder on my desktop?

Appreciate the help!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I found some code that works. But I have one small issue.


Right now the macro is looking at all the files in my inbox. I want to change this to a folder i have setup as "test". I replaced the word "$Inbox" with "$test" but it didn't work. Gave me the error "Run-time error '91' Object variable or With block variable not set" and highlighted the line containing Set noDocument = noView.GetFirstDocument

Any ideas?

Here is my code:


Option Explicit

Const stPath As String = "c:\Attachments\"
Const EMBED_ATTACHMENT As Long = 1454
Const RICHTEXT As Long = 1

Sub Save_Remove_Attachments()
Dim noSession As Object
Dim noDatabase As Object
Dim noView As Object
Dim noDocument As Object
Dim noNextDocument As Object

'Embedded objects are of the datatype Variant.
Dim vaItem As Variant
Dim vaAttachment As Variant

'Instantiate the Notes session.
Set noSession = CreateObject("Notes.NotesSession")

'Instantiate the actual Notes database.
'(Here is the personal e-mail database used and since it's a
'local database no reference is made to any server.)
Set noDatabase = noSession.GetDatabase("", "")
If Not noDatabase.IsOpen = True Then noDatabase.Openmail 'open the mail part of it

'Folders are views in Lotus Notes and in this example the Inbox is used.
Set noView = noDatabase.GetView("($test)")

'Get the first document in the defined view.
Set noDocument = noView.GetFirstDocument

'Iterate through all the e-mails in the view Inbox.
Do Until noDocument Is Nothing
'Although the following approach is not necessary for this
'kind of operations it may be a good approach to use in general.
Set noNextDocument = noView.GetNextDocument(noDocument)

'Check if the document has an attachment or not.
If noDocument.HasEmbedded Then
Set vaItem = noDocument.GetFirstItem("Body")
If vaItem.Type = RICHTEXT Then
For Each vaAttachment In vaItem.EmbeddedObjects
If vaAttachment.Type = EMBED_ATTACHMENT Then
'Save the attached file into the new folder and remove it from the e-mail.
With vaAttachment
.ExtractFile stPath & vaAttachment.Name
' .Remove
End With
'Save the e-mail in order to reflect the deleting of the attached file.
'(A more sophisticated approach may be considered if several e-mails have
'several attachments in order to avoid a repeately saving of one e-mail.)
noDocument.Save True, False
End If
Next vaAttachment
End If
End If
Set noDocument = noNextDocument
Loop

'Release objects from memory.
Set noNextDocument = Nothing
Set noDocument = Nothing
Set noView = Nothing
Set noDatabase = Nothing
Set noSession = Nothing

MsgBox "All the attachments in the Inbox have successfully been saved and removed." _
, vbInformation
End Sub
 
Upvote 0
Hi

I know this is a old post. But can be usufeul for someone as it was for me

Set noView = noDatabase.GetView("($test)")

Just need to remove the second parentesis and the $
Should be like that

Set noView = noDatabase.GetView("test")

And this way should work
 
Upvote 0
I tried the script shared earlier by bcurrey and then corrected the script as suggested by you. Even with all this the script could not be saved as it kept on throwing errors. Request your advise. I am using this script with Lotus Notes version 9.0.1

I believe, this script being an old one needs some corrections to make it work with the newer version of Lotus Notes. I am looking for the same functionality of saving all attachments of the mails in the current VIEW/FOLDER. There is also a need to save multiple attachments of an email to the designated folder.

Request your support at the earliest.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,613
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top