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 24103 times)
anastassism
YaBB Newbies
*
Offline



Posts: 20
Send email from XML file data
Mar 29th, 2011 at 8:59am
 
Hello,
can the application read the user data 'e-mail' from an xml file? every time a new file is created in the watch folder (file i wanted to be emailed) an xml file is created with the same file name that includes the user's email. So is it possible for every new file created, watchdirectory to read the new xml file that combibes the file?

thanks

xml file:

<photo_information>
 <date>2011/03/28</date>
 <time>11:17:59</time>
 <user_data>"user's email"</user_data>
 <photobooth_images_folder>C:\Photos</photobooth_images_folder>
- <photos>
 <photo image="1">20110328_111759p0003.JPG</photo>
 <output>prints\20110328_111759.jpg</output>
 </photos>
 </photo_information>
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #1 - Mar 29th, 2011 at 9:12am
 
Hi,

Interesting issue. I think it is possible using the "run a bat file" task.

If you can post (or email me) a zip with a few example files (both xml and the file to be detected), I will have a look how the script should work.

Gert
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 #2 - Mar 29th, 2011 at 9:59am
 
Gert,
thanks for the prompt reply.
I am sending you couple of images and xml files.
Back to top
 

XML.zip (247 KB | )
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #3 - Mar 29th, 2011 at 11:18am
 
I have not much time today, but I will have a look tomorrow.
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 #4 - Mar 30th, 2011 at 6:12am
 
Hi,

I looked at the xml and pictures you attached.
Quote:
every time a new file is created in the watch folder (file i wanted to be emailed) an xml file is created with the same file name that includes the user's email


The .xml filename doesn't correspond to the jpg filename.
The jpg names inside the xml do not correspond to the jpg filenames.

How can I know/decide which xml "corresponds" to which picture?

Your zip has the following files:
20110328_115031p0003.xml (inside it mentions 20110328_115031p0003.JPG and prints\20110328_115031.jpg)
20110328_115105p0004.xml (inside it mentions 20110328_115105p0004.JPG and prints\20110328_115105.jpg)
HFP_20110328_115031.jpg
HFP_20110328_115105.jpg

As you can see there is no exact match on filenames.

Please tell me when the script I write for you is called for the detected xml file 20110328_115031p0003.xml how it should "decide" which jpg to attach to the email.
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 #5 - Mar 31st, 2011 at 10:32am
 
Gert,

sorry for the bad info that i sent you. Let me try to explain...

My system is basically a photobooth. In every session it takes from 1 to 4 photos in order to process a photostrip (the file that i want to be emailed).

The photos will have the below filenames:
20110328_115031p0003.JPG
20110328_115031p0004.JPG
etc...

The xml file will take the filename of the first photo of the session (20110328_115031p0003.xml)

Inside the xml information the photostrip filename is: prints\20110328_115031.jpg, and the actual file will have the same name.

Please let me know if you need further explanation.

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



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #6 - Mar 31st, 2011 at 12:48pm
 
So if I understand correctly:

* I can ignore all non-xml files
* the script should email to the email-address in the xml file
* it should attach the ONE jpg listed in the xml file

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 #7 - Mar 31st, 2011 at 2:04pm
 
* I can ignore all non-xml files
Yes


* the script should email to the email-address in the xml file
Yes


* it should attach the ONE jpg listed in the xml file
It should attach the 'i.e. prints\20110328_115031.jpg' file in the xml file


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



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #8 - Mar 31st, 2011 at 2:12pm
 
I actually need the full path to the file, so where is the prints directory located (the full path to the jpg listed in the xml, not a relative path like 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 #9 - Mar 31st, 2011 at 2:17pm
 
The full path normally is different for every project. Will it be possible for me to change your script? If not please use the following path: c:\photobooth\prints
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #10 - Mar 31st, 2011 at 2:20pm
 
ok.

Alternatively, if this "prints" directory is relative to where the XML is found, I can automatically determine the correct directory. Is that the case?
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 #11 - Mar 31st, 2011 at 2:32pm
 
the relation will always be like the below example:

c:\....projectA\prints

xml file in the 'projectA' directory
file should be attached in the 'prints' directory
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #12 - Mar 31st, 2011 at 2:41pm
 
Perfect, so if the file
[b]C:\Whatever\Directory\hello.xml[/b]
is detected, and inside it says
[b]<output>prints\20110328_115031.jpg</output>[/b]

the attached file should be
[b]C:\Whatever\Directory\prints\20110328_115031.jpg[/b]

Do you want the script to REMOVE the xml and attached picture after processing?
or
Do you want the script to MOVE the xml and attached file to a backup location (where?), outside the monitored directory?
or
leave the files alone.

Oh, one more question......
I assume this will NEVER be network locations (\\server\share\photos), but always local drives (C:, D:). Correct?
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 #13 - Mar 31st, 2011 at 2:57pm
 
Perfect, so if the file
C:\Whatever\Directory\hello.xml
is detected, and inside it says
<output>prints\20110328_115031.jpg</output>

Correct


the attached file should be
C:\Whatever\Directory\prints\20110328_115031.jpg

Correct


Do you want the script to REMOVE the xml and attached picture after processing?
or
Do you want the script to MOVE the xml and attached file to a backup location (where?), outside the monitored directory?
or
leave the files alone.

leave the files alone


Oh, one more question......
I assume this will NEVER be network locations (\\server\share\photos), but always local drives (C:, D:). Correct?
Correct


Thank you very much for your patience and efforts!
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #14 - Mar 31st, 2011 at 3:02pm
 
I like a little scripting challenge Wink

I may work on this later today or otherwise tomorrow. You will have something to test before the weekend.
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 #15 - Apr 1st, 2011 at 12:41pm
 
Oh boy, this was harder than expected.

Copy the script below and save it as "C:\Scripts\SendPicture.bat"
Code:
@echo off
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%==

rem change the path to the picture to an absolute path
rem (add the directory of the XML file in front)
SET PICTURE=%WD_FILE_D%%PICTURE%



Call :SendEmail

rem we are done!
GOTO :EOF



rem from the detected XML file, get the email address
rem   <user_data>xxxx@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 from the detected XML file, get the picture
rem       <photo image="1">20110328_115031p0003.JPG</photo>

:GetThePicture
SET PICTURE=
for /F "usebackq tokens=1-3 delims=<>" %%A in (`type "%WD_FILE%"`) do (
  if "%%A" == "photo image="1"" (
     set PICTURE=%%B
     GOTO :EOF
  )
  if "%%B" == "photo image="1"" (
     set PICTURE=%%C
     GOTO :EOF
  )
  if "%%C" == "photo image="1"" (
     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

 



Create a new task using the "run bat file" plugin ( http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBat.html ).
Let the script be called for XML files only (see http://www.watchdirectory.net/wdhelp/help/filter_events.html and http://www.watchdirectory.net/wdhelp/help/edit_filter.html ).

I have not tested much, but this should work. Let me know.

Do you like my work? Please consider making a donation to the Alzheimer foundation
http://blog-en.gdpsoftware.com/2011/02/world-without-alzheimers-disease.html

Gert
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 #16 - Apr 1st, 2011 at 1:54pm
 
Great!! I will test it later on today, and i will send you my feedback.

Once more...thank you!
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #17 - Apr 1st, 2011 at 2:05pm
 
oops, after reading your specs again and looking at the script, I see I made a mistake.

The script reads <photo image="1">20110328_115031p0003.JPG</photo> instead of <output>prints\20110328_115031.jpg</output>.

Please use this script:
Code:
@echo off
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%==

rem change the path to the picture to an absolute path
rem (add the directory of the XML file in front)
SET PICTURE=%WD_FILE_D%%PICTURE%



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 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 #18 - Apr 4th, 2011 at 2:40pm
 
Dear Gert,

Does the script read for specific jpg and xml filenames (i.e prints\20110328_115031.jpg)

Maybe for once more i wasn't clear enough, but in every new sequence my system saves the files with different filenames.

Unfortunately i cant make it work. Please let me know if this is the case with the filenames. If not i might have not put the right filters to call for XML files only.

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



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #19 - Apr 4th, 2011 at 3:09pm
 
Are you using the correct script?

Note that I posted a new version ~1 hour after your response, see the posts above.
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 #20 - Apr 4th, 2011 at 4:11pm
 
Yes i used the correct script.

I need to test it again and see if i have set it up incorrectly.

If i can't make the test tonight i will let you know of my progress again the 16th of April (will be out of office due to business trip)

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



Posts: 20
Re: Send email from XML file data
Reply #21 - Apr 28th, 2011 at 10:17am
 
Hello Gert,

Sorry for the late reply but i've been travelling a lot lately.

The script works! Great work and i cant thank you enough...

I will send you a pm..
Back to top
 
 
IP Logged
 
anastassism
YaBB Newbies
*
Offline



Posts: 20
Re: Send email from XML file data
Reply #22 - May 10th, 2011 at 12:44pm
 
Hi Gert,

If i would like to change the directory name that should be monitored for changes, and it's not on the xml file, is it possible to do it with this script?

Thanks
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Send email from XML file data
Reply #23 - May 11th, 2011 at 8:56am
 
The monitored directory doesn't matter as long as the paths inside the XML are still relative to where the file is found.

Maybe I don't understand your question.
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 #24 - May 11th, 2011 at 10:53am
 
what if i want to monitor a non relative path to the xml? is there an easy solution?
Back to top
 
 
IP Logged
 
Pages: 1 2