Friday, December 13, 2024

Can I automatically send an email with attachments to recipients listed in an Excel spreadsheet (.xlsx) when the file is added to a specific folder?

Utilizing macOS Monterey 14.6.1 and Microsoft Outlook for Mac version 16.89.3. I’m struggling to identify a fair and equitable resolution to this topic in the online forum.

Here’s an improved version:

I’m developing a folder action service/script that monitors a designated folder for new Excel files, ensuring that only Excel files are added due to specific restrictions. Upon file addition, the script will automatically send the file via Outlook to the email address listed in cell B2 of the spreadsheet, facilitating seamless communication.

I’ve successfully used ChatGPT for this task. Unfortunately, the script may not work consistently across different email clients.

You’re still stuck on this chatbot’s guidance that isn’t yielding the desired results? When dropping a file into the designated folder, I observe the gear icon spinning momentarily within the menu bar; yet, none of the expected visual cues or notifications materialize – no dialogue boxes appear, nor do any error messages pop up, and the Outlook email inbox remains unaffected.

on including folder objects to this_folder after receiving added_items
    repeat with added_item in added_items
        set filePath to POSIX path of added_item
        -- Examine if the file is an Excel file
        if filePath ends with ".xlsx" then
            show dialog "File added: " & (title of added_item) -- Debugging message
            attempt
                -- Open the Excel file to learn the e-mail tackle
                inform software "Microsoft Excel"
                    open filePath
                    delay 1 -- Look forward to Excel to open
                    set recipientEmail to worth of cell "B2" of energetic sheet
                    shut energetic workbook saving no -- Shut the workbook with out saving
                finish inform
                
                -- Guarantee recipientEmail is legitimate
                if recipientEmail just isn't lacking worth then
                    -- Put together the e-mail
                    inform software "Microsoft Outlook"
                        set newMessage to make new outgoing message with properties {topic:"Your Requested Excel File", content material:"Good day,nnPlease discover the requested Excel file hooked up.nnBest regards,nYour Identify"}
                        make new recipient at newMessage with properties {electronic mail tackle:{tackle:recipientEmail}}
                        make new attachment at newMessage with properties {file:added_item}
                        ship newMessage
                    finish inform
                else
                    show dialog "No electronic mail tackle present in cell B2 of " & (title of added_item)
                finish if
            on error errMsg
                show dialog "Error processing file: " & errMsg
            finish attempt
        finish if
    finish repeat
finish including folder objects to

Thanks to your time.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles