[Résolu] PDFCreator et envoi de mail automatique. PJ illisible
Publié : mar. 29 juil. 2014 13:04

Afin d'optimiser le travail d'un client, j'utilise une imprimante spécifique + profil.
Tout fonctionne correctement jusqu'à la réception, le fichier PDF est correctement généré (lisible) puis envoyé mais impossible de l'ouvrir.
Le script utilisé, est celui fourni par PDF Creator (v1.7.3)
Testé avec GS 9.10 (intégré) et GS 9.14.
Code : Tout sélectionner
' SendMail script
' Part of PDFCreator
' License: GPLv3
' Homepage: http://www.pdfforge.org/
' Windows Scripting Host version: 5.1
' Version: 1.0.0.0
' Date: May 23, 2012
' Author: Philip Chinery
' Comments: This script sends a mail using blat
' The script requires blat.exe (http://www.blat.net/)
Dim cmdline, subject, receipient, sender, server, user, password, bodyFile, blat, additionalParams, file
' Please configure this section to suit your needs
' Receipient's E-Mail address
receipient = "client@entreprise.fr"
' Your E-Mail address
sender = "serveur@entreprise.fr"
' Subject for the mail
subject = "Devis"
' Server name or IP address
server = "smtp.entreprise.fr"
' user name - leave empty if none required
user = ""
' password - leave empty if none required
password = ""
' a plain text file containing the mail body text
bodyFile = "c:\Temp\Edition.pdf"
' Path to blat.exe (including blat.exe)
blat = "C:\Blat\blat.exe"
' Add other blat params here, if required. i.e. you can use " -log C:\blat-log.txt" for logging
additionalParams = "-log C:\blat-log.txt"
' the actual scripts starts here
Set Wshshell = CreateObject("wscript.shell")
Set objArgs = WScript.Arguments
If objArgs.Count = 0 Then
MsgBox "This script needs a parameter!", vbExclamation, AppTitle
WScript.Quit
End If
if bodyFile = "" then
MsgBox "The body file is not defined. Please configure this script first!"
WScript.Quit
end if
file = objArgs(0)
cmdline = """" & blat & """ """ & bodyFile & """ -t " & receipient & " -server " & server & " -f " & sender & " -s """ & subject & """ " & additionalParams & " -attach """ & file & """"
if user "" then
cmdline = cmdline & " -u " & user
end if
if password "" then
cmdline = cmdline & " -pw " & password
end if
wshshell.Run cmdline, 1, True
