IPB

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> [AS] Envoi de mail au format HTML avec une pièce jointe
Options
Taki Tak
posté 8 Sep 2014, 12:33
Message #1


Nouveau Membre


Groupe : Membres
Messages : 2
Inscrit : 8 Sep 2014
Membre no 191 886



Bonjour à tous,

Comme le titre du topic l'indique, je souhaite pouvoir envoyer un mail au format HTML et y insérer une pièce jointe.

Le souci c'est que je peux soit :
- envoyer un mail au format HTML sans pièce jointe
- envoyer un mail normal avec pièce jointe

Mais dès que j'essai de faire les deux, impossible.

Voici mon script simplifié :

CODE
set toAddress to "[email protected]"
set textSubject to "test"
set toName to "Nom"
set textBody to "<!DOCTYPE><html><head><title>Test</title><meta charset="utf-8"></head><body style="width:700px; border:1px solid black; padding:20px; margin:20px auto; height:150px">Test</body></html>"
set theAttachment to "chemin du fichier"

tell application "Mail"
set refMessage to make new outgoing message with properties {subject:textSubject, visible:false}

tell refMessage
set html content to textBody
make new attachment with properties {file name:theAttachment}
make new to recipient at end of every to recipient with properties {name:toName, address:toAddress}
end tell
send refMessage
end tell


Si j'enlève la ligne "set html content to textBody", la pièce jointe part sans problème.
Go to the top of the page
 
+Quote Post
Jaypee
posté 8 Sep 2014, 15:40
Message #2


Macbidouilleur d'Or !
*****

Groupe : Membres
Messages : 2 486
Inscrit : 29 Aug 2002
Membre no 3 340



Et si le HTML body commençait à <body> et finissait à </body> ce serait probablement plus "cohérent". AppleScript s'occupe déjà du header etc... (edit: ou avec html en plus <html><body>...</body></html>)
Cela empêche de l'utiliser comme moteur de Spam.
J-P

Ce message a été modifié par Jaypee - 8 Sep 2014, 15:56.
Go to the top of the page
 
+Quote Post
Taki Tak
posté 8 Sep 2014, 16:58
Message #3


Nouveau Membre


Groupe : Membres
Messages : 2
Inscrit : 8 Sep 2014
Membre no 191 886



J'ai corrigé merci.

Finalement je me suis tourner vers une solution en Perl.

Merci quand même.

Ce message a été modifié par Taki Tak - 8 Sep 2014, 16:58.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Nous sommes le : 18th April 2024 - 04:23