Hi. Ich habe folgendes Skript seit langem im Einsatz:
$g_szVersion = 'PDF Mailer'
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)
Opt("RunErrorsFatal", 0)
Opt("TrayAutoPause", 0)
Global $Sender, $Recipient, $MailUser, $MailPass
Global $Enable_Encryption = True
If $CmdLine[0] > 0 Then
If StringInStr($CmdLine[1], "1") AND StringInStr($CmdLine[1], "2") Then Exit ;;can't run both at the same time!
If StringInStr($CmdLine[1], "1") Then
$Sender = 'xxx1@xxx.de'
$Recipient = 'xxx2@xxx.de'
$MailUser = 'xxx'
$MailPass = 'xxx'
ElseIf StringInStr($CmdLine[1], "2") Then
$Sender = 'xxx2@xxx.de'
$Recipient = 'xxx1@xxx.de'
$MailUser = 'xxx'
$MailPass = 'xxx'
ElseIf StringInStr($CmdLine[1], "/?") Then
MsgBox(32, $g_szVersion, "This program has two arguments, which must be in order." & @CRLF & _
"The first argument is country, which can either be 1or 2." & @CRLF & @CRLF & _
"The second argument is optional, controlling encryption." & @CRLF & _
"Passing noencrypt as the second argument will disable encryption")
Exit
Else
Exit
EndIf
If $CmdLine[0] > 1 Then
If StringInStr($CmdLine[2], "noencrypt") Then $Enable_Encryption = False
EndIf
Else
Exit
EndIf
#region Configuration Settings
Global Const $Blowfish_Password = 'xxx'
Global Const $POP3Server = 'pop3.xxx.de'
Global Const $SMTPServer = 'smtp.xxx.de'
;SendMail Configuration
Global Const $SendMail = 'D:\scanner\scanner\sendmail'
Global Const $PDF_Dir = 'D:\scanner\sendmail\Emails'
;GetMail Configuration
Global Const $GetMail = 'D:\scanner\getmail'
Global Const $source = 'D:\scanner\getmail\Emails' ; Location of encrypted PDF files
Global Const $dest = 'D:\scanner\getmail\Emails\Archives' ; Location of decrypted PDF files
Global Const $GSPrintDir = 'D:\scanner\Print\Ghostgum\gsview' ;Path to PDF Printer Program
#endregion Configuration Settings
#region Do Not Edit!!!!!
#region GetMail Functions
Func GetMail()
If Not FileExists($source) Then DirCreate($source)
If Not FileExists($dest) Then DirCreate($dest)
FileChangeDir($GetMail)
RunWait('getmail.exe -u ' & $MailUser & ' -pw ' & $MailPass & ' -s ' & $POP3Server & ' -xtract -delete', '', @SW_HIDE)
FileDelete('*.txt')
FileDelete('*.out')
FileMove('*.pdf', $source & '\*.pdf', 1)
Sleep(1000)
Local $file = FileFindFirstFile($source & '\*.pdf')
If $file = -1 Then Return 0
While 1
Local $pdffile = FileFindNextFile($file)
If @error Then ExitLoop
If $Enable_Encryption Then
RunWait('bfish.exe /I:"' & $source & '\' & $pdffile & '" /O:"' & $dest & '\' & $pdffile & '" /P:"' & $Blowfish_Password & '" /D /Q', "", @SW_HIDE)
If FileExists($dest & '\' & $pdffile) Then
;File successfully decrypted, print it!
Local $WorkingDir = @WorkingDir
FileChangeDir($GSPrintDir)
RunWait('gsprint.exe "' & $dest & '\' & $pdffile & '"', $GSPrintDir, @SW_HIDE)
FileChangeDir($WorkingDir)
EndIf
Else
FileMove($source & '\*.pdf', $dest & '\')
Local $WorkingDir = @WorkingDir
FileChangeDir($GSPrintDir)
RunWait('gsprint.exe "' & $dest & '\' & $pdffile & '"', $GSPrintDir, @SW_HIDE)
FileChangeDir($WorkingDir)
EndIf
While FileExists($source & '\' & $pdffile)
FileDelete($source & '\' & $pdffile) ;delete the encrypted version
WEnd
WEnd
FileClose($file)
Return 1
EndFunc ;==>GetMail
#endregion
#region SendMail Functions
Func SendMail()
If Not FileExists($PDF_Dir) Then DirCreate($PDF_Dir)
If Not FileExists($PDF_Dir & '\Encrypted\') Then DirCreate($PDF_Dir & '\Encrypted\')
If Not FileExists($PDF_Dir & '\Archives\') Then DirCreate($PDF_Dir & '\Archives\')
If Not FileExists($PDF_Dir & '\*.pdf') Then Return 0
Local $PDFfiles[1]
FileChangeDir($SendMail)
Local $PDFHandle = FileFindFirstFile($PDF_Dir & '\*.pdf')
While 1
Local $file = FileFindNextFile($PDFHandle)
If $file <> '' Then
ReDim $PDFfiles[ (UBound($PDFfiles) + 1) ]
$PDFfiles[0] += 1
$PDFfiles[ (UBound($PDFfiles) - 1) ] = $file
Else
ExitLoop
EndIf
WEnd
FileClose($PDFHandle)
For $x = 1 To $PDFfiles[0]
If $Enable_Encryption = True Then
RunWait('bfish.exe /I:"' & $PDF_Dir & '\' & $PDFfiles[$x] & '" /O:"' & $PDF_Dir & '\Encrypted\' & $PDFfiles[$x] & '" /P:"' & $Blowfish_Password & '" /E /Q', "", @SW_HIDE)
FileSend($PDFfiles[$x], $PDF_Dir & '\Encrypted\' & $PDFfiles[$x])
Else
FileSend($PDFfiles[$x], $PDF_Dir & '\' & $PDFfiles[$x])
EndIf
FileMove($PDF_Dir & '\' & $PDFfiles[$x], $PDF_Dir & '\Archives\' & $PDFfiles[$x])
FileDelete($PDF_Dir & '\Encrypted\' & $PDFfiles[$x])
Next
Return 1
EndFunc ;==>SendMail
Func FileSend($FileName, $Attachment)
Local $objMessage = ObjCreate('CDO.Message')
With $objMessage
.Subject = $FileName
.Sender = $Sender
.From = $Sender
.To = $Recipient
.TextBody = $FileName & ' is attached and encrypted.'
.AddAttachment ($Attachment)
EndWith
With $objMessage.Configuration.Fields
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SMTPServer
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $MailUser
.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $MailPass
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
EndWith
$objMessage.Send
Return 1
EndFunc ;==>FileSend
#endregion
Func _ReduceMemoryUsage()
Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Return $ai_Return[0]
EndFunc
#endregion Do Not Edit
While 1
If (@Hour >= 7) AND ((@HOUR & @MIN) <=1630) Then
GetMail()
Sleep(1000 * 15) ;;Wait for 15 seconds
SendMail()
EndIf
_ReduceMemoryUsage()
Sleep(1000 * 60 * 4.75) ;;Wait for 5 minutes
WEnd
Alles anzeigen
Bis jetzt lief das Ganze auf einem Windows 2000 Betriebssystem, nun soll es auf einem 64 Bit Windows Vista laufen. Es funktioniert auch alles tadellos, die Dokumente werden verschickt und empfangen, aber nicht gedruckt. Ich vermute, dass es an dem GSViewer liegt. Davon habe ich nun auch die 64 Bit Version installiert, aber da diese neue Dateinamen hat, muss ich das Skript neu kompilieren. Genau da scheitert es schon bei Zeile 5, da die Ausdrücke anscheinend nicht richtig sind. Könnt ihr mir hier helfen? Theoretisch könnte das Skript auch radikal gekürzt werdenn, da sich Empfänger und Sender nun in einem Netzwerk befinden. Dann müsste die Datein ja nurnoch in einem Freigegebenen Ordner abgelegt werden und von dort aus gedruckt werden. Dann könnte man sich den Schritt des verschlüsselns und per Email versenden sparen. Aber ich hab keine Idee wie ich das umprogrammiere.