Consulting

Results 1 to 9 of 9

Thread: Access to read Outlook script

  1. #1

    Access to read Outlook script

    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?
    Attached Files Attached Files

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    337
    Location
    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/show...utlook-Mailbox
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    I did try but for some reason, it does not read the mails and the attachmentsin the WeeklyProceedings inbox.

  4. #4
    When I tried to edit and paste the code between the #, I get an error

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Quote Originally Posted by rolling_zep View Post
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    337
    Location
    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.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    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?
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  8. #8
    No, I am trying to run this from Access Command event

  9. #9
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    337
    Location
    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.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •