raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.39k stars 3.09k forks source link

[Apple Mail] ... #7015

Closed Christian-548376 closed 1 year ago

Christian-548376 commented 1 year ago

Extension

https://www.raycast.com/yug2005/mail

Description

When using the 'Compose new Message' command I see in the "From" email field my multiple icloud addresses as one long text... like so: Myname@mac.comMyname@icloud.comMyname@me.com.....

Steps To Reproduce

n/a

Current Behaviour

No response

Expected Behaviour

No response

raycastbot commented 1 year ago

Thank you for opening this issue!

🔔 @yug2005 @ikupenov @pernielsentikaer you might want to have a look.

💡 Tip: Once the issue is resolved, comment @raycastbot close this issue to close it.

ikupenov commented 1 year ago

Hmm, can you give me the result you get when run this Apple Script (you can do that in Script Editor.app on your Mac)? Feel free to blur any sensitive info.

set output to ""
tell application "Mail"
    set mailAccounts to every account
    repeat with mailAcc in mailAccounts
        repeat 1 times
            if (count of every mailbox of mailAcc) is 0 then exit repeat
            set accId to id of mailAcc
            set accName to name of mailAcc
            set accUser to user name of mailAcc
            set fullName to full name of mailAcc
            set accEmail to email addresses of mailAcc
            try
                set mainMailbox to (first mailbox of mailAcc whose name is "All Mail")
                set numUnread to unread count of mainMailbox
            on error
                try
                    set mainMailbox to (first mailbox of mailAcc whose name is "INBOX")
                    set numUnread to unread count of mainMailbox
                on error
                    set numUnread to 0
                end try
            end try
            set output to output & accId & "," & accName & "," & accUser & "," & fullName & "," & accEmail & "," & numUnread & "
"
        end repeat
    end repeat
end tell
return output
Christian-548376 commented 1 year ago

Here we go:

"236A6716-XXXXXXXXXXXXXXXXX,iCloud,<email01>@mac.com,<My full Name>,<email01>@mac.com<email01>@me.com<email02>@icloud.com<email02>@me.com<email03>@icloud.com<email03>@me.com,0
A9BF76B0-XXXXXXXXXXXXXXXXXX,Google,<email01>@gmail.com,<My full Name>,<email01>@gmail.com,0
"

I have a couple of icloud addresses / aliases from the old @me.com apple domain..

Hope this all helps.

Regards, Christian

ikupenov commented 1 year ago

That's weird. Accounts are separated by a new line for me, and we're splitting based on that. Which MacOS and Mail versions are you running?

Also can you try running it again with \n used as a separator instead of " ":

set output to ""
tell application "Mail"
    set mailAccounts to every account
    repeat with mailAcc in mailAccounts
        repeat 1 times
            if (count of every mailbox of mailAcc) is 0 then exit repeat
            set accId to id of mailAcc
            set accName to name of mailAcc
            set accUser to user name of mailAcc
            set fullName to full name of mailAcc
            set accEmail to email addresses of mailAcc
            try
                set mainMailbox to (first mailbox of mailAcc whose name is "All Mail")
                set numUnread to unread count of mainMailbox
            on error
                try
                    set mainMailbox to (first mailbox of mailAcc whose name is "INBOX")
                    set numUnread to unread count of mainMailbox
                on error
                    set numUnread to 0
                end try
            end try
            set output to output & accId & "," & accName & "," & accUser & "," & fullName & "," & accEmail & "," & numUnread & "\n"
        end repeat
    end repeat
end tell
return output
Christian-548376 commented 1 year ago

I have run the new script as well, same result...

The accounts iCloud/Google are separated by a new line, but what is probably the issue is that my icloud account contains multiple addresses (see screen) and accEmail, is not separated (at least that string appears when I use the "Compare New Message" as the "From")


I am using Ventura 13.5 Beta (22G5038d) / Mail Version 16.0 (3731.700.2)

Mail
Christian-548376 commented 1 year ago

Not sure if that reply from Bing AI will do the trick...

Bing
ikupenov commented 1 year ago

I didn't think of that edge case at all 😓. The script below should work but it needs to be handled in the extension as well. I'll try to fix that soon!

set output to ""
tell application "Mail"
    set mailAccounts to every account
    repeat with mailAcc in mailAccounts
        repeat 1 times
            if (count of every mailbox of mailAcc) is 0 then exit repeat
            set accId to id of mailAcc
            set accName to name of mailAcc
            set accUser to user name of mailAcc
            set fullName to full name of mailAcc
            set accEmails to email addresses of mailAcc
            try
                set mainMailbox to (first mailbox of mailAcc whose name is "All Mail")
                set numUnread to unread count of mainMailbox
            on error
                try
                    set mainMailbox to (first mailbox of mailAcc whose name is "INBOX")
                    set numUnread to unread count of mainMailbox
                on error
                    set numUnread to 0
                end try
            end try

            repeat with accEmail in accEmails
                set output to output & accId & "," & accName & "," & accUser & "," & fullName & "," & accEmail & "," & numUnread & "\n"
            end repeat
        end repeat
    end repeat
end tell
return output
Christian-548376 commented 1 year ago

👍