Applescript & Mail
I am very new to applescript and I am having some teathing troubles. I am trying to create a list of email addresses from emails arriving into a particular mailbox. I think I have the logic right,
1. Open Mail
2. Go to the mailbox i need
3. Go to the first message
4. Get the email address
5. Put the address in a text file
6. Repeat for all the emails in the mailbox
I'm stuck on number 2, generally how to select items i need in Mail, any help with this would be great.
If anyone also knows of a good book that might lean towards scripting with Mail, it woud be really helpful.
Thanks in advance!
Hi
Did you ever figure this out?
Ben
Similar Messages
-
Help in Applescript Mail option
Hi Forum,
I'm using tis applescript, to check the folder for files and sent mail via applescript.
It works quiet good. The problem is if the document does not contain any files, also the mail is sent to the receipient.
I'm requesting forum , to correct this applescript, to send the mail only if the files are found inside the folder.
on run
set myFolder to "/Users/wander5/Desktop/QuarkRescueFolder"
set {TID, text item delimiters} to {text item delimiters, linefeed}
tell application "Finder" to set myFiles to name of files of (POSIX file myFolder as alias)
set newNames to paragraphs of (do shell script "sed 's/\\(.*\\)\\((.*)\\)/\\2 \\1/' <<< " & quoted form of (myFiles as text))
repeat with i from 1 to count myFiles
tell application "System Events" to set name of (first file of folder myFolder whose name is (item 1 of myFiles)) to (item 1 of newNames)
end repeat
set text item delimiters to TID
set fileList to list folder myFolder without invisibles
repeat with tFile in fileList
set recipientName to "Wander5"
set recipientAddress to "[email protected]"
set theSubject to "Please check Files has been completly copied from server"
set theContent to "check files have been copied"
tell application "Mail"
# # Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
##end tell
end repeat
end run
Many thanks,I didn't test but don't you just need to test fileList's length/count before you loop the list…?
on run
set myFolder to "/Users/wander5/Desktop/QuarkRescueFolder"
set {TID, text item delimiters} to {text item delimiters, linefeed}
tell application "Finder" to set myFiles to name of files of (POSIX file myFolder as alias)
set newNames to paragraphs of (do shell script "sed 's/\\(.*\\)\\((.*)\\)/\\2 \\1/' <<< " & quoted form of (myFiles as text))
repeat with i from 1 to count myFiles
tell application "System Events" to set name of (first file of folder myFolder whose name is (item 1 of myFiles)) to (item 1 of newNames)
end repeat
set text item delimiters to TID
set fileList to list folder myFolder without invisibles
if length of fileList > 0 then -- Its not an empty list…
repeat with tFile in fileList
set recipientName to "Wander5"
set recipientAddress to "[email protected]"
set theSubject to "Please check Files has been completly copied from server"
set theContent to "check files have been copied"
tell application "Mail"
# # Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
end repeat
end if
end run -
AppleScript, Mail.app - Forward command doubles content - Mountain Lion
I'm trying to write an AppleScript to Forward or Redirect an email. It works fine but doubles up the content when I change any of the new emails details. Eg the subject, 'to recipient', etc.
My code is:
tell application "Mail"
set theSelection to selection
set theForwardedMessage to forward (item 1 of theSelection) with opening window
tell theForwardedMessage
set subject to "{plain} " & subject
end tell
end tell
This is under Mountain Lion, 10.8.2, Mail.app is version 6.2 (1499).
Any help would be much appreciated.
TIA, James.Thanks Pierre. That's really helpful.
On its own that didn't work, but if I put in a 'display dialog' command it does. Ie this works:
tell application "Mail"
set theSelection to selection
set theForwardedMessage to forward (item 1 of theSelection) with opening window
set theSubject to subject of theForwardedMessage
activate
tell application "System Events" to tell process "Mail"
display dialog "1"
tell text field "Subject:" of window 1
set focused to true
set value to "{plain} " & theSubject
end tell
end tell
end tell
I also want the recipient filled in, but it doesn't work for me. In this code it displays the 'A' dialog then stops:
tell application "Mail"
set theSelection to selection
set theForwardedMessage to forward (item 1 of theSelection) with opening window
set theSubject to subject of theForwardedMessage
activate
tell application "System Events" to tell process "Mail"
display dialog "1"
tell text field "Subject:" of window 1
set focused to true
set value to "{plain} " & theSubject
end tell
tell text field "To:" of window 1
display dialog "A"
set focused to true
display dialog "B"
set value to "[email protected]"
end tell
end tell
end tell
Ie it never gets to the 'B' dialog.
So perhaps that field is called something else? How do you find out what the 'To:' field is called?
Thanks,
James. -
Applescript Mail duplicate removal
Hi all,
I have a problem with duplicate email messages and thought I'd take a stab at an applescript solution. Tried using a few sorting/searching type strategies but the size of the mailboxes just made it too slow and unwieldy. But I noticed that in the viewer, duplicate messages are not visible. (Seems like if Mail has the ability to notice duplicates it should just as easily make it an option to flush them, but maybe I'm naive.) Anyway, thought I would use that knowledge to remove duplicates myself with the script below. It works so far, but my concern is whether there are *any* reason a message would not be visible yet not a duplicate. Does anyone know? This is lightning fast compared to my other attempts and so far seems to only find duplicates.
tell application "Mail"
set theViewer to front message viewer
set msglist to visible messages of theViewer
set IDlist to {}
repeat with msg in msglist
copy (id of msg) to end of IDlist
end repeat
set allmsgs to messages of theViewer
set dupcount to 0
repeat with msg in allmsgs
if (id of msg) is not in IDlist then
move msg to mailbox "Deleteme" of account "myaccount"
set dupcount to dupcount + 1
end if
end repeat
say "Moved " & (dupcount as rich text) & " messages to mailbox deleteme"
end tellDid you have any luck with this script as I have also been looking for something to do this, at the moment I'm having to use Entourage to perform the function.
-
Can AppleScript/Mail recover from non-existent email address?
I have an AppleScript which automatically sends HTML emails after a delay of a few days from receipt of an incoming email produced by a web form. It works well except for one issue:
The address it sends to are picked up from the web form so I have been testing failure modes for various badly formed email addresses. Most fail gracefully with NDNs except if the domain does not exist. In this case Mail opens a dialog window with "Cannot send message using server etc". This is not good for an unattended Mac automatically processing thousands of emails a day. Mail appears not to inform AppleScript of this glitch.
Any thoughts about a solution would be appreciated.
I only have Tiger and Leopard but this script will eventually run on a recent Mac.This is a style thing, but I try to write my code so it is easy to debug.
if (do shell script "x='" & w & "';
z=${x##*@};
t=`dig +short ${z%>*} MX`;
echo ${#t}") > 0 then display dialog "send"
It is hard to debug what is being passed to Unix.
I'd write this something like
[[ I have not tested this ! ]]
[ I have not taken in Hiroto's comments ]:
-- I write the code so as to debug it. I would not assume the statement above would work the first time.
-- I let the log statements in the final code. They do not do anything outside of the script editor.
set toUnix to "x='" & w & "';
z=${x##*@};
t=`dig +short ${z%>*} MX`;
echo ${#t}"
log "toUnix = " & toUnix
set result to do shell toUnix
log "result = " & result
-- I do not understand this statement. Shoudn't we be testing for the length of result? Or not equal to null?
if result > 0 then
display dialog "send" -
So, here's my problem.
I have a message URL which goes something along the line of "message://%3c<Some string of numbers, hyphons etc.>%3e"
What I want it to have a message id of the format "message id ### of mailbox "<Some mailbox name>" of account "Google""
At the moment, I'm opening the URL, setting the message to the selection, and that variable is then of the form above that I want it.
Does anyone know of any script that will take in a Message URL and churn out a Message ID for Mail?
Thanks to everyone!!!Well, for a start you're not setting your AppleScript variable to a URL - you're setting it to the content of the email. Sure, that content may contain a URL, but it will also contain other characters such as the return after the URL, which is what the %0A translates to.
In other words you're assuming the content of the email is just a URL, which isn't the case - it's a URL followed by a new line.
If you're confident that the format of the email will be consistent and you just need to nix the last character you can use something like:
set theText to content of theMessage
set theText to (characters 1 through -2 of theText) as text
This will chop off the last character, whatever that may be.
If it's also just the linefeed at the end of the URL you're concerned about, you could also:
set theText to paragraph 1 of (content of theMessage)
This will ignore anything past the first line - useful if there's ever any other content in the message.
One other observation - your script says:
set the clipboard to theText
I don't know what you plan to do with the URL in the rest of the script (if there is any), but in general you should avoid manipulating the clipboard in your script. Since this is running as a mail rule, it could get invoked at any time, including when you're working in some other application and may have copied some data to the process of some other workflow. As soon as this mail triggers you lose your previous clipboard contents in favor of the URL in the email.
I would look more closely at what you intend to do with the URL - for example if you plan to pass that URL to some other application then look to do so directly, not via the clipboard. -
Applescript Mail Remove Attachments
Hi,
Can anybody help with this?
I want a Mail rule to remove any attachments received from a particular sender. There is no built in rule for this so figure an applescript could do the job, but I haven't managed to get one to work.
There is a person whose messages I need to read, but he insists on attaching >10MB images with each message.
Many thanks,
DThis looks more than a job that needs to be done by your mailserver :-/
When you would use a pop account you could run a script on the emlx files in your Mail-Folder and remove the attachments but this could lead to inconsistent data (hacked emlx file and you mail database).. The cleanest way would be a mailserver that filters attachments. -
AppleScript - Mail.app Multiple Users
Hello:
Can someone guide me on how to use Applescripts to switch Mail.app between two
differant users. I read an article about a setup that is like profiles for
Firefox or Thunderbird.
I have tried typing into Applescripts the same formular like is used for the above
to make a profile for Mail but it does not work.
Thanks in advance.Hi BD Aqua,
There is suppose to be a way to write a script within Applescripts for Mail
to let two users switch back & forth between there seperate e-mail accounts
withing the same Tiger account. Just like the way you can ues profile manager
with either Firefox or Thunderbird.
My wife & I use the same Tiger with auto log-in. So we want to creat "identities"
to use with Mail. -
I am trying to write a Applescript rule for Mail. The rule is triggered when a Mail with a specific title arrives. Here is the script that gets triggered.
<script>
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Finder" to set pathToAttachments to (path to desktop folder as string)
tell application "Mail"
repeat with theMessage in theMessages
if theMessage's mail attachments is not {} then
repeat with theAttachment in theMessage's mail attachments
set theFileName to pathToAttachments & (theMessage's id as string) & space & theAttachment's name
try
save theAttachment in theFileName
on error errnum
end try
end repeat
end if
tell application "Preview" to open theFileName
tell application "Finder" to delete theFileName
end repeat
end tell
end perform mail action with messages
end using terms from
</script>
Okay, the actual script actually tells NeatWorks to open theFileName, but most people do not have NeatWorks, and the problem occurs with Preview also.
So, the rule works if the mail message is selected, run after the mail has arrived. I would like the rule to automatically run when the message first arrives. But the script doesn't trigger.
My other rules that are not based Applescript run when a message first arrives. Does anyone know why?It might be a threading issue, but I am not sure it is as you think.
I do see a likely threading error with Applescript with Services. I set up a Speak Service using Automator; it speaks the selected text. I have set that up on a Keyboard shortcut. If I invoke the Speak Service, it runs fine. If I invoke the Speak Service a second time while the first block of text is being read, The speak block continues to execute proprerly, but I get a Workflow Error for the second block of selected text. My guess, as you stated, is Applescript is not re-entrant and that generates the error.
If the mail problem were a threading issue, I would expect the rule to work the first time but fail the second time the rule got invoked. The rule does not even run properly the first time or the only time the rule gets invoked.
It maybe a threading error in so far as the rule gets triggered as soon as the rule is detirmined to be true, but the piece of mail might not be completely loaded. With the imcoplete message, the Applescript cannot completely and correctly check the email.
This is further supported by the fact, if the mail is executed on the e-mail as a lone piece of mail in the Inbox, The Applescript rule runs as expected. -
Applescript Mail.app to add attachment to a reply
I am writing some scripts to automate my e-mail workflow, and part of it relies on replying to a message with some revised files attached.
Problem is, Mail.app doesn't seem to allow Applescript to include attachments to replies, only to new outgoing messages.
So, this works:
set mailAttach to alias "somefile"
tell application "Mail"
set listSelectedMail to selection
set selectedMail to last item of listSelectedMail
set replyMail to make new outgoing message
activate
tell replyMail
set visible to true
make new attachment with properties {file name:mailAttach} at after the last paragraph
end tell
end tell
...while this doesn't:
set mailAttach to alias "somefile"
tell application "Mail"
set listSelectedMail to selection
set selectedMail to last item of listSelectedMail
set replyMail to reply selectedMail with reply to all
activate
tell replyMail
set visible to true
make new attachment with properties {file name:mailAttach} at after the last paragraph
end tell
end tell
Is it really the case that Applescript can't add attachments to replies, or am I overlooking something?
Of course I could just make a new message adding "Re:" to the subject, but I want to keep the quoted contents of the message I am replying to.
Does anyone have any suggestion?
Cheers,
JeffHi Jeff,
The following script seems to work pretty well (at least with the default preferences of Mail):
set mailAttach to POSIX file "some POSIX path" as alias
tell application "Mail"
set listSelectedMail to selection
set selectedMail to last item of listSelectedMail
set replyMail to reply selectedMail with opening window and reply to all
tell replyMail
set theTO to {name, address} of to recipients
set theCC to {name, address} of cc recipients
set theBCC to {name, address} of bcc recipients
set theSubject to subject
end tell
activate
tell application "System Events" to keystroke "acw" using command down
set theMessage to make new outgoing message
tell theMessage
make new attachment with properties {file name:mailAttach} at the end
set {theNames, theAddresses} to {item 1, item 2} of theTO
repeat with k from 1 to (count theAddresses)
set {theName, theAddress} to {item k of theNames, item k of theAddresses}
if theName is missing value then set theName to ""
make new to recipient with properties {name:theName, address:theAddress}
end repeat
set {theNames, theAddresses} to {item 1, item 2} of theCC
repeat with k from 1 to (count theAddresses)
set {theName, theAddress} to {item k of theNames, item k of theAddresses}
if theName is missing value then set theName to ""
make new cc recipient with properties {name:theName, address:theAddress}
end repeat
set {theNames, theAddresses} to {item 1, item 2} of theBCC
repeat with k from 1 to (count theAddresses)
set {theName, theAddress} to {item k of theNames, item k of theAddresses}
if theName is missing value then set theName to ""
make new bcc recipient with properties {name:theName, address:theAddress}
end repeat
set the subject to theSubject
set visible to true
end tell
delay 1 -- adjust if necessary
tell application "System Events"
key code 124 using {command down} -- ⌘→
keystroke return
keystroke "v" using command down -- ⌘V
key code 126 using {command down} -- ⌘↑
end tell
end tell -
Applescript: mail text selection
I thought of something that would be handy this morning: what if I could select text and mail it immediately. It sounded like something for automator, but as I am not familiar with how it works, I went and found this here:http://forums.macrumors.com/showthread.php?t=779050.
It works, but not the way I want, it inserts the text into the To: box instead of the body. Also, is there a way to have it open address book and let me select an address to mail to, prompt me for a subject, and properly insert the selection into the body?
Thank You,
Ga776mApplescript questions should be asked in Mac OS X Technologies
I'll see if this can be moved. -
AppleScript Mail, Compare Date and Move to Folder
tell (current date) to set dateForm to (its weekday as string) & (its month as string) & " " & day & ", " & year
--set dateForm to "Tuesday, March 6, 2012" -- for testing on your Sample Email for Script, remove this line to matches current date
-- formats the current date like "Tuesday, February 29, 2012"
tell application "Mail" to set emailsSource to messages of mailbox "Good Tuesday" of account "HappyGoLucky45"
repeat with anEmail in emailsSource
tell application "Mail" to set theSource to source of anEmail
set tLines to paragraphs of theSource
set tc to (count tLines)
if tc > 165 then
set foundDate to false
repeat with i from 120 to 190
if getDate(item i of tLines) then
set foundDate to true
exit repeat
end if
end repeat
if foundDate then
set theMailbox to "zOld"
tell application "Mail"
move the anEmail to mailbox theMailbox of account "HappyGoLucky45"
end tell
end if
end if
end repeat
on getDate(theText)
set k to 0
repeat with thisWord in words of theText
set k to k + 1
if thisWord is in ¬
{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} then
try
if (exists word (k + 1) of theText as integer) ¬
and (exists word (k + 2) of theText as integer) then
set theFoundDate to word k of theText & " " & ¬
word (k + 1) of theText & ", " & ¬
word (k + 2) of theText
if date theFoundDate < (date dateForm) then return true
end if
end try
end if
end repeat
return false
end getDate
--Below is how the email appears and the Date I am trying to compare to the Current Date (DateForm)
--The format of the email has changed and I can't figure out how to fix it.
--This is to move old messages to different folder
--About this event
--Tuesday, October 29, 2013 at 11:55 PM (EDT)Anyone have any thoughts?
-
Applescript & Mail: fail reading from list
I'm trying to write a script to mark duplicates in a mailbox by creating a list of existing message IDs and mark the ones already in the list. While it does create the correct list, duplicate IDs won't be detected. Is there a bug or is it my script?
try
tell application "Mail"
set msg_count to count of message in message viewer 1
if msg_count = 0 then
display dialog "Please select the folders you want to scan for duplicates." with icon 1 buttons {"Okay"} default button 1
else
set all_msg to (every message in message viewer 1)
set id_list to {}
set dup_count to 0
repeat with this_msg in all_msg
try
set msg_id to (content of every header of this_msg whose name is "Message-ID")
on error
set msg_id to ""
set background color of this_msg to blue
end try
if msg_id is in id_list then --problem here?
set background color of this_msg to gray
set dup_count to dup_count + 1
else if msg_id is not "" then
set the end of id_list to msg_id
end if
set msg_count to msg_count - 1
if msg_count mod 100 = 0 and msg_count > 0 then say (msg_count as string) & " messages remaining"
end repeat
--choose from list id_list
if dup_count is 0 then
say "done. no duplicates found"
else
say "done. " & dup_count & " duplicates found."
end if
end if
end tell
on error the error_message number the error_number
-- don't display error message if the user canceled a dialog within the [try] and [on error] lines above
if the error_number is not -128 then
set the error_text to "Error: " & the error_number & ". " & the error_message
display dialog the error_text buttons {"Cancel"} default button 1
else
error number -128
end if
end tryWell, I was thinking maybe the message id is, by default, set as list item instead of string and that might be the reason why it can't find it in the list though the list contains the id. So I just edited it and it works!
I forgot to mention that the script was taken from <a href=http://homepage.mac.com/barryw/">Barry Wainwright's "Remove Duplicates" for Entourage.
Here's the edited blocks:
<pre>repeat with this_msg in all_msg
try
set msg_id to (content of every header ¬
of this_msg whose name is "Message-ID") ¬
as string -- problem was here
if msg_id is "" then set background color ¬
of this_msg to blue
end try
if msg_id is in id_list then
set background color of this_msg to gray
set flagged status of this_msg to ¬
true -- for easy deletion
set dup_count to dup_count + 1
else if msg_id is not "" then
set the end of id_list to msg_id
end if
set msg_count to msg_count - 1
if msg_count mod 100 = 0 and msg_count > 0 ¬
then say (msg_count as string) ¬
& " messages remaining"
end repeat
if dup_count is 0 then
say "done. no duplicates found"
else if dup_count is 1 then
say "done. 1 duplicate found"
-- sometimes you only find one
else
say "done. " & dup_count & " duplicates found."
end if
</pre> -
Applescript mail used to work...
but just stopped...my app receives email via a mail rule, processes it via osascript, then sends a reply...this worked until 12mar:
tell application "Mail"
tell (make new outgoing message with properties ¬
{subject:"re: " & cmd, content:(resultMsg as string) & return})
set sender to my dvrEmail
make new to recipient at end of to recipients with properties {address:replyTo}
send
end tell
end tell
here's the sent msg:
Subject: re: tvpi2DVR:send2sammy
From: [email protected]
Date: March 12, 2010 8:25:40 AM EST
To: [email protected]
[email protected] - tvpi2DVR:send2sammy
/tmp/1003_12__08_2534-program.tvpi
to
/Volumes/DVR/recordings/ScheduleMar_17_2010__08_00_5-1PM.tvpi
crontab updated
but by 16mar, the recipient was no longer getting set, thus no send. everything else is fine..the unsent msg sits in drafts, showing all expected inputs but no recipient:
Subject: re: tvpi2DVR:send2sammy
From: [email protected]
Date: March 16, 2010 11:48:02 AM EDT
[email protected] - tvpi2DVR:send2sammy
/tmp/1003_16__11_4718-program-2.tvpi
to
/Volumes/DVR/recordings/ScheduleMar_22_2010__09_00_5-1PM.tvpi
crontab updated
a simple standalone test script works, but the osascript invocation simply ignores the replyTo value, which is valid (and was output in the body of the msg)
i don't recall when i applied the 10.6.3 update, but perhaps something changed with mail...any ideas?someone mentioned needing a delay in mail, so i put one just before the send, and it works again...seems snow leopard has event timing issues:-(
-
I found this on Mactech. All I did was add the line "make new outgoing........", well, it does NOT work. What do you have to do to make Mail trigger an applescript. All I want to do is when I an email reminder, to just make a new email message with Happy Birthday in the Subject. I'll click the stationary and add a birthday background. Any help would be appreciated.
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with a from 1 to count theSelectedMessages
make new outgoing message with properties {visible:true, subject:"Happy Birthday", content:"Happy Birthday "}
end repeat
end perform mail action with messages
end using terms fromsorry but your suggestion did NOT work. Here is what I wrote and it did NOT make a difference the script will NOT generate an outgoing message.
using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set senderName to (extract name from sender of newMessage)
say "You've just received an email from " & senderName
say (subject of newMessage) as string
if (subject of newMessage) contains "birthday" then
tell application "Mail"
activate
make new outgoing message with properties {visible:true, subject:"Happy Birthday", content:"Happy Birthday "}
end tell
end if
end tell
end repeat
What I was able to do was embed a line of code to call another script that does successfully create an out going message. Here is the successful script.
using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set senderName to (extract name from sender of newMessage)
say "You've just received an email from " & senderName
say (subject of newMessage) as string
end tell
end repeat
tell application "Finder"
open "Macintosh HD:Users:Shawn:Documents:Applescripts:Mail scripts:make outgoing email happy birthday5.app"
end tell
end perform mail action with messages
end using terms from
here is the make birthday5 app
tell application "Mail"
activate
make new outgoing message with properties {visible:true, subject:"Happy Birthday", content:"Happy Birthday "}
end tell
Now when I get my birthday reminder, according to the "Rule" set up in preferences, if the subject contains "birthday" the script will read the name and subject and generate an outgoing message with Happy Birthday in the Subject and Body.....all I have to do is add some birthday stationary, type in a sappy line and viola, done. See why I love Macs so much.
Maybe you are looking for
-
Screen goes of during watching movie
During watching movie the screen goes off (black) after x amount of time, just as when im doing nothing. This is terribly annoying when watching a movie,, what can i do about it??
-
Configuration of OIM on windows 7 fails with "setup.exe has stopped working
I have tried everything I can think of and I can't run the config.bat for OIM. OID OVD etc installs and works fine. Windows 7 Professional 64 bit 8GB memory I can't believe I'm the only one. If anyone has a suggestion. Thanks
-
How to change the language of playlist from italian to english
how can i change the language of my playlist from italian to english even i change already the language setting still the playlist is italian
-
I am having problems with my home wifi.
This is my second iphone5s. I have been having problems with the wifi. I can connect to the wifi for a couple days but all of a sudden it'll disconnect and I will try to access it again but it'll ask for a user name and password and it isn't my route
-
Hi guys, I've been trying to connected by Mac Mini late 2009 to my bose surround system using a 3.5mm cable. However, it produces a very buzzy sound and the sound only comes out from 2-3 out of 5 speakers. Is there any way that I can make it go to th