WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Pages: 1 2 
Send email from XML file data (Read 24106 times)
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #25 - May 11th, 2011 at 11:01am
 
Sorry, you have to explain better, please give a few examples. I think you are saying that the picture mentioned inside the xml is not found relative to the detected xml, but I am not sure.
Please explain it like

I am monitoring C:\Pictures
Detected file is C:\Pictures\Booth1\123.xml
123.xml contains <output>prints\20110328_115031.jpg</output>
the picture to attach is located in C:\prints\20110328_115031.jpg

Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #26 - May 11th, 2011 at 11:21am
 
sorry, let me try to explain better:

the path of the picture to attach, will be different with the one mentioned in the xml.

I am monitoring C:\Photobooth
Detected file is C:\Photobooth\123.xml
123.xml contains <output>prints\20110328_115031.jpg</output>
the picture to attach is located in C:\whatever\whatever\whatever\20110328_115031.jpg

i was thinking if i could use, in combination with the script, the 'directory to watch' option in the 'Run any Bat File' task..
Back to top
 
 
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #27 - May 11th, 2011 at 11:22am
 
the file name of the picture to attach, will be the same in the monitored directory and with the one mentioned in the xml....
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #28 - May 11th, 2011 at 11:33am
 
do basically
Quote:
123.xml contains <output>prints\20110328_115031.jpg</output>


you want the script to ignore the "prints\" part and the jpg to attach (20110328_115031.jpg) is in the same directory as the detected XML?
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #29 - May 11th, 2011 at 11:58am
 
i want to be able, somehow, to tell the script the path that the jpg to attach is saved.

this path will not be mentioned inside the xml. the xml will always mention <output>prints\20110328_115031.jpg</output>, but the a 20110328_115031.jpg to attach will be stored in a totally different directory.
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #30 - May 11th, 2011 at 12:02pm
 
Ah, ok.

Let me think about it for a bit.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #31 - May 12th, 2011 at 10:19am
 
Hi,

Give this script a try (not tested by me). You need to set the path to pictures at the second line of the script. It reads the picture-name from the XML as before, but only uses the filename (1234.jpg).

Code:
@echo off
SET PICTUREPATH=C:\Whatever\Something
rem make sure we are called for an XML file, otherwise ignore this event
IF "%WD_FILE_E%" NEQ "XML" GOTO :EOF

Call :GetTheEmail
IF "%EMAILADDRESS%" EQU "" GOTO :EOF
echo ==%EMAILADDRESS%==

Call :GetThePicture
IF "%PICTURE%" EQU "" GOTO :EOF
echo ==%PICTURE%==

Call :StripPath
IF "%PICNOPATH%" EQU "" GOTO :EOF
echo ==%PICNOPATH%==

rem change the path to the picture to an absolute path
SET PICTURE=%PICTUREPATH%\%PICNOPATH%



Call :SendEmail

rem we are done!
GOTO :EOF



rem from the detected XML file, get the email address
rem   <user_data>a.mavroidis@gmail.com</user_data>

:GetTheEmail
SET EMAILADDRESS=
for /F "usebackq tokens=1-3 delims=<>" %%A in (`type "%WD_FILE%"`) do (
  if "%%A" == "user_data" (
     set EMAILADDRESS=%%B
     GOTO :EOF
  )
  if "%%B" == "user_data" (
     set EMAILADDRESS=%%C
     GOTO :EOF
  )
  if "%%C" == "user_data" (
     set EMAILADDRESS=%%D
     GOTO :EOF
  )
)

GOTO :EOF



rem remove the path from the filename
rem so print\abc.jpg becomes abc.jpg

:StripPath
SET PICNOPATH=
:StripPathAgain
IF "%PICTURE%" EQU "" GOTO :EOF
SET LASTPOS=%PICTURE:~-1%
SET PICTURE=%PICTURE:~0,-1%
IF "%LASTPOS%" EQU "\" GOTO :EOF
SET PICNOPATH=%LASTPOS%%PICNOPATH%
GOTO :StripPathAgain

rem from the detected XML file, get the picture
rem	     <output>prints\20110328_115031.jpg</output>


:GetThePicture
SET PICTURE=
for /F "usebackq tokens=1-3 delims=<>" %%A in (`type "%WD_FILE%"`) do (
  if "%%A" == "output" (
     set PICTURE=%%B
     GOTO :EOF
  )
  if "%%B" == "output" (
     set PICTURE=%%C
     GOTO :EOF
  )
  if "%%C" == "output" (
     set PICTURE=%%D
     GOTO :EOF
  )
)

GOTO :EOF




GOTO :EOF
rem actually send the email
rem see also http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEmail.html

:SendEmail

set EMAILFILE=%WD_TASKDIR%\..\System.Mail\Out\%WD_CONFIG%_%WD_CUREVT%.TMP
echo Photostrip picture attached > "%EMAILFILE%"
echo ^<%EMAILADDRESS%^> >> "%EMAILFILE%"
echo. >> "%EMAILFILE%"
rem -- send a bcc of all emails, if you don't want this anymore
rem -- replace it with the same line as above (just a .)
echo ^<secretbcc@johndoe.com^> >> "%EMAILFILE%"
echo %PICTURE% >> "%EMAILFILE%"
echo pecunia non olet >> "%EMAILFILE%"
echo Hi, >> "%EMAILFILE%"
echo Please find attached the photostrip we just created for you. >> "%EMAILFILE%"
echo Thanks for doing business with us, >> "%EMAILFILE%"
echo    Anastassism >> "%EMAILFILE%"
rem okay, the script is created, now rename it so the wdPostMan program processes it.
ren "%EMAILFILE%" %WD_CONFIG%_%WD_CUREVT%.wdmail


GOTO :EOF
 

Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #32 - May 12th, 2011 at 2:02pm
 
I tested it couple of times but the script didn't work for me  Sad

Will test it more later or tomorrow.

Thank you
Back to top
 
 
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #33 - May 18th, 2011 at 5:54pm
 
Hi again,

I tested the new script, it sends the email but it doesn't attach the file... any ideas?

Thank you
Back to top
 
 
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #34 - May 18th, 2011 at 6:14pm
 
It works!! So nothing to worry about...

Thank you
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #35 - May 19th, 2011 at 9:02am
 
Did you have to change anything to get it to work?
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #36 - May 19th, 2011 at 2:05pm
 
No i didn't change anything.. it was my fault, i did confuse the folders that wanted to be monitored..

I send you an email to gert (at) gdpsoftware (dot) com
Back to top
 
 
IP Logged
 
Pages: 1 2