View Full Version : Access to read Outlook script
rolling_zep
08-11-2023, 07:21 AM
Hi,
I am new to this site.I posted this on Access Forum.
Please delete it, if this is not allowed.
We manually run a rule everyday, which executes a script in Outlook. This reads attachments in the inbox from folder, WeeklyProceedings Mailbox and saves the attachments to a folder in the shared directory, S.
The Access database imports these Outlook attachments files into a table.
Since this job needs to be done before all users log in, it is done manually by a User at 8.30 am everyday.
I am trying to automate and run this as a Scheduled task without manual intervention.
How do I convert the Outlook script to Access VBA script so that it can be executed either by a macro or an event?
June7
08-11-2023, 11:02 AM
Should paste that code into your post between CODE tags. Use the # icon from post edit toolbar. Can edit your post.
"Outlook script" is VBA. Have you tried code in an Access module?
Duplicate thread http://www.vbaexpress.com/forum/showthread.php?71024-To-read-Outlook-Mailbox
rolling_zep
08-11-2023, 11:09 AM
I did try but for some reason, it does not read the mails and the attachmentsin the WeeklyProceedings inbox.
rolling_zep
08-11-2023, 11:13 AM
When I tried to edit and paste the code between the #, I get an error :(
Aussiebear
08-11-2023, 01:31 PM
When I tried to edit and paste the code between the #, I get an error :(
There's a time limit on how long is available for members to be able to go back and edit threads.
June7
08-11-2023, 01:39 PM
If you still get the Edit button then should be able to edit. They must have been in edit if they were trying to paste.
gmayor
08-12-2023, 09:21 AM
Are you running this code in Outlook? If so provided you have identified the folder path correctly it should work. If you change the code to
If X > 0 Then
For y = 1 To X
'getting the attachment name
strFileName = olItem.Attachments.Item(y).FileName
'saving the attachment in a temporary location
Debug.Print strFileName
'olItem.Attachments.Item(y).SaveAsFile "C:\Users\prasad.govindarajan\Testing\" & olItem.Attachments.Item(y).FileName
Next y
End If
does it list filenames in the immediate window?
Note your code makes no allowance for duplicated filenames, which could be an issue, depending on what the attachments are. It might also be advisable to ensure that you are only processing the required attachments. Have you considered creating the macro as a script that processes the e-mails as they arrive via a rule?
rolling_zep
08-12-2023, 11:16 AM
No, I am trying to run this from Access Command event
June7
08-12-2023, 11:52 AM
What is "Access Command" event? Exactly where are you running this code? A button Click event?
Posting under Access forum is probably best because you want to code in Access. Continue discussion in other thread.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.