Re: [AS] Scripter mail

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Madert Pascal via Applescript_fr
Date:  
À: La liste AppleScript Francophone
CC: Madert Pascal
Sujet: Re: [AS] Scripter mail
Bonsoir

Merci.
En essayant vite fait comme ça, avant de partir, aucun des 2 ne fonctionne.
L’autre script, avec « Number » fonctionne très bien, mais pas avec « Excel » (du moins, je n’arrive pas à modifier le script sans qu’il y ait des erreurs)
Je me disais que peut-être qu'il serait possible d’utiliser 2 scripts, le votre pour transformer le corps du mail en tableur « Number » et un autre pour l’enregistrer au format « Excel »
Le 2e script étant appeler par le 1er une fois l’export fait.

À vous lire.
Cordialement,
Pascal



> Le 21 oct. 2019 à 18:15, Yvan KOENIG via Applescript_fr <applescript_fr@???> a écrit :
>
>
> Bonsoir
>
> Je viens de retrouver deux scripts datant de 2017 utilisant les règles pour enregistrer les pièces jointes.
> Ça pourrait servir de point de départ mais je répète que le support des dites règles est pour le moins facétieux.
>
> script #1
>
> using terms from application "Mail"
>     on perform mail action with messages theMessages for rule theRule
>         -- The folder to save the attachments in (must already exist)

>         
>         
>         -- Save in a sub-folder based on the name of the rule in Mail

>         
>         set subFolder to name of theRule
>         tell application "Finder"
>             set attachmentsFolder to ((path to home folder as text) & "Dropbox:Attachments") as text
>             if not (exists folder subFolder of folder attachmentsFolder) then
>                 make new folder at attachmentsFolder with properties {name:subFolder}
>             end if
>         end tell
>         tell application "Mail"

>             
>             repeat with eachMessage in theMessages

>                 
>                 set {year:y, month:m, day:d, hours:h, minutes:min} to eachMessage's date sent
>                 set timeStamp to ("" & y & "-" & my pad(m as integer) & "-" & my pad(d) & "-" & my pad(h) & "-" & my pad(min))

>                 
>                 try
>                     -- Save the attachment
>                     repeat with theAttachment in eachMessage's mail attachments

>                         
>                         set originalName to name of theAttachment
>                         set savePath to attachmentsFolder & ":" & subFolder & ":" & timeStamp & " " & originalName
>                         try
>                             save theAttachment in file (savePath)
>                         end try
>                     end repeat

>                     
>                     display dialog subFolder
>                 end try
>             end repeat

>             
>         end tell
>     end perform mail action with messages
> end using terms from

>
> -- Adds leading zeros to date components
> on pad(n)
>     return text -2 thru -1 of ("00" & n)
> end padd

>
> script #2
>
> (*<pre style="
> font-family: Monaco, 'Courier New', Courier, monospace;
> font-size: 10px;
> font-weight: normal;
> margin: 0px;
> padding: 5px;
> border: 1px solid #000000;
> width: 720px; height: 340px;
> color: #000000;
> background-color: #E6E6EE;
> overflow: auto;"
> title="this text can be pasted into the AppleScript Editor">
> *)
> (*
> Set a Mail Rule to Save Message and Attachment to Desktop.
> To save attachments to another another folder on the desktop (i.e. Attachments) create the folder and then
> change tell application "Finder" to set pathToAttachments to (path to desktop folder as string) & "Attachments:"
> *)
>
> using terms from application "Mail"
>     on perform mail action with messages theMessages
>         tell application "Finder" to set ptd to (path to desktop folder) as string
>         tell application "Finder" to set pathToAttachments to (path to desktop folder) as string
>         tell application "Mail"
>             repeat with theMessage in theMessages
>                 set d_recd to date received of theMessage as string
>                 set d_recd to ReplaceText(d_recd, ":", " ") of me
>                 set d_recd to ReplaceText(d_recd, ",", " ") of me
>                 set theText to content of theMessage
>                 if theMessage's mail attachments is not {} then
>                     repeat with theAttachment in theMessage's mail attachments
>                         set theFileName to pathToAttachments & (theMessage's subject) & " (Attachment From " & (theMessage's sender) & " Sent " & d_recd & ")" & space & theAttachment's name
>                         try
>                             save theAttachment in theFileName
>                         on error errnum
>                         end try
>                     end repeat
>                 end if
>                 set theFile to ptd & (theMessage's subject) & " (From " & (theMessage's sender) & " Sent " & d_recd & ")" & ".txt"
>                 set theFileID to open for access file theFile with write permission
>                 write theText to theFileID
>                 close access theFileID
>             end repeat
>         end tell
>     end perform mail action with messages
> end using terms from

>
> on ReplaceText(theString, fString, rString)
>     set current_Delimiters to text item delimiters of AppleScript
>     set AppleScript's text item delimiters to fString
>     set sList to every text item of theString
>     set AppleScript's text item delimiters to rString
>     set newString to sList as string
>     set AppleScript's text item delimiters to current_Delimiters
>     return newString
> end ReplaceText (*</pre>*)

>
>
> Yvan KOENIG (VALLAURIS, France) lundi 21 octobre 2019 18:15:16
>
>
>
> _______________________________________________
> Applescript_fr mailing list
> Applescript_fr@???
> http://listes.patpro.net/mailman/listinfo/applescript_fr


_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr