content: use AppleScript version "2.4" -- Yosemite (10.10) or later
  use scripting additions
  
  (*
  	Moves the selected Mail messages to the destination mailbox under the specified mail account.
  	
  	mailAccount: the NAME of the mail account in Mail.app (e.g. Exchange, Gmail, Work).
  				This is whatever you called the account when you created it. Look in the 
  				list of mailboxes in the left hand panel.
  	destinationMailbox: the name of the folder (Folders are called Mailboxes in Mail.app) you
  				want to move the messages to.
  *)
  on processMailMessages(mailAccount, destinationMailbox)
  	tell application "Mail"
  		set selectedMessages to selection
  		repeat with currentMessage in selectedMessages
  			move currentMessage to mailbox destinationMailbox of account mailAccount
  		end repeat
  	end tell
  end processMailMessages
  
  
  (*
  	Originally borrowed from Yvan Koenig, contributor to Macscripter.net
  	Orginal forum post: https://macscripter.net/viewtopic.php?pid=179732#p179732
  	
  	selectedMessages: the selection of messages from Mail.app
  	myNameList: List containing your name in the following format - {"Last First, First Name"}
  *)
  on saveMailMessagesAsPDF(selectedMessages, myNameList)
  	
  	set attachmentsFolder to (choose folder) as text
  	
  	---------------------------------------
  	repeat with eachMessage in selectedMessages
  		
  		tell application "Mail"
  			open eachMessage
  			delay 0.5
  			set wName to name of window 1
  			
  			tell eachMessage # extracts datas from the selected message
  				set sender_Name to extract name from its sender
  				set sender_Mail to extract address from its sender
  				set mail_Subject to subject
  				set mail_Date to date received # will keep the time component
  				set target_name to (name of its to recipient)
  			end tell # the message
  		end tell # Mail
  		
  		tell mail_Date
  			set theYear to year
  			set theMonth to its month as number
  			set theDay to day
  			set theHour to its hours
  			set theMinutes to its minutes
  			set theSeconds to its seconds
  		end tell
  		set begName to (theYear as text) & "-" & text -2 thru -1 of ((100 + theMonth) as text) & "-" & text -2 thru -1 of ((100 + theDay) as text) & space & text -2 thru -1 of ((100 + theHour) as text) & "." & text -2 thru -1 of ((100 + theMinutes) as text) & "." & text -2 thru -1 of ((100 + theSeconds) as text) & " Email "
  		
  		if sender_Name is in myNameList then
  			set begName to begName & "to " & target_name
  		else
  			set begName to begName & "from " & sender_Name
  		end if
  		
  		set thePDFname to begName & " - " & my supprime(mail_Subject, {":", "/"}) & ".PDF"
  		set pdfPath to (path to desktop as text) & thePDFname
  		
  		-- Print the opened email
  		
  		tell application "System Events"
  			tell process "Mail"
  				set frontmost to true
  				keystroke "p" using {command down} # Issue the Print shortcut
  				tell window wName
  					repeat
  						try
  							if (exists pop up button 1 of sheet 1) then exit repeat
  						end try
  						delay 0.2
  					end repeat
  					
  					--name of menu buttons of sheet 1 of window wName
  					--> {"PDF"} # but I don't know if it's spelled this way worldwide
  					tell sheet 1
  						set PDFButton to first menu button
  						click PDFButton
  						-- name of menu items of menu 1 of PDFButton
  						--> {"Ouvrir le PDF dans AperÃ§u", "Enregistrer au format PDFâ€¦", "Enregistrer au format PostScriptâ€¦", "Faxer le document PDFâ€¦", missing value, "@ PDF-BAT.qfilter", "@ PDF-prÃ©presse CMJN.qfilter", "@ PDF-web.qfilter", "@ PDFX3-ISO.qfilter", "Add PDF to iTunes", "Envoyer le document PDF par courrier Ã©lectronique", "Enregistrer le document PDF dans le dossier de reÃ§us web", missing value, "Modifier le menuâ€¦"}
  						click menu item 2 of menu 1 of PDFButton
  						
  						repeat
  							if exists sheet 1 then exit repeat # the Print sheet exists, exit the loop!
  							delay 0.1
  						end repeat
  						
  						tell sheet 1
  							keystroke "d" using {command down} # Set the Desktop as destination folder
  							set value of text field 1 to thePDFname # Set the name of the new PDF
  							keystroke return
  						end tell # sheet 1 (the Save As one)
  					end tell # sheet 1 of window wName
  				end tell
  			end tell # process "Mail"
  			
  			repeat
  				if exists disk item pdfPath then exit repeat # Now the pdf is really available on the Desktop
  				delay 0.1
  			end repeat
  		end tell # System Events
  		
  		# We may move the PDF to its final location
  		set pdfPath to quoted form of POSIX path of pdfPath
  		do shell script "mv " & pdfPath & space & quoted form of (POSIX path of attachmentsFolder)
  		
  		# Now speak again to Mail
  		tell application "Mail"
  			try
  				# Here only if the message has attacments
  				set num to 1
  				repeat with theAttachment in eachMessage's mail attachments
  					set fileName to begName & " Attachment - " & num & " - " & theAttachment's name
  					save theAttachment in file (attachmentsFolder & my supprime(fileName, {":", "/"})) # I know, I'm a bit paranoid
  					set num to num + 1
  				end repeat
  			end try
  			close window wName
  		end tell
  	end repeat # with eachMessage
  	
  end saveMailMessagesAsPDF
  
  (*
  	Originally borrowed from Yvan Koenig, contributor to Macscripter.net
  	Orginal forum post: https://macscripter.net/viewtopic.php?pid=179732#p179732
  *)
  on supprime(t, d)
  	local oTIDs, l
  	set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
  	set l to text items of t
  	set AppleScript's text item delimiters to ""
  	set t to l as text
  	set AppleScript's text item delimiters to oTIDs
  	return t
  end supprime
  
  #=====
  