Let>SENDMAIL_STATUS=1
Let>subject=Ads confirmation
Let>me=[email protected]
Let>myname=HC Addesk
GetDate>date
GetFileList>c:\Testdir\*.pdf,files
Separate>files,;,file_names
If>file_names_count=0,end
Let>k=0
Repeat>k
Let>k=k+1
Until>k,file_names_count
Label>end
endIf>
Let>attachments=files
Let>recipients=[email protected]
Let>body=This is the copy of your ads submitted to The HC on %date% %CRLF%
If you have any question, please contact your representative.%CRLF%
%CRLF%
Thank you
SMTPSendMail>recipients,mailhost.chron.com,me,myname,subject,body,attachments
Message>Result of SendMail: %SMTP_RESULT%
==================================
There are two problems that I encounters,
1, If there's no file in the directory, it still send out a message instead of just end the script.
2, The script wont break with the command %CRLF%
I need the expert to look at this code
Moderators: Dorian (MJT support), JRL
Let>SENDMAIL_STATUS=1
Let>subject=Ads confirmation
Let>me=[email protected]
Let>myname=HC Addesk
GetDate>date
GetFileList>c:\Testdir\*.pdf,files
Separate>files,;,file_names
If>file_names_count=0,end
Let>attachments=files
Let>recipients=[email protected]
Rem>' Note, the following "Let" is all on one line, including the "Thank You"
Let>body=This is the copy of your ads submitted to The HC on %date%%CRLF%If you have any question, please contact your representative.%CRLF%%CRLF%Thank you
SMTPSendMail>recipients,mailhost.chron.com,me,myname,subject,body,attachments
Message>Result of SendMail: %SMTP_RESULT%
Label>end
Problem 1 was because you had the send-the-email part after the "Label>end", so your script would jump to that if there were 0 files found, and then still exceute the rest of the script.
Problem 2... don't know, it worked for me. Perhaps you didn't have all the "let>body" stuff on one line.
You also didn't need the k=k+1 loop. You can probably get away with using "seperate" too, and check the length of "%files%" instead, but I kept it close to how you had it so you could still see how it worked.
Let>subject=Ads confirmation
Let>me=[email protected]
Let>myname=HC Addesk
GetDate>date
GetFileList>c:\Testdir\*.pdf,files
Separate>files,;,file_names
If>file_names_count=0,end
Let>attachments=files
Let>recipients=[email protected]
Rem>' Note, the following "Let" is all on one line, including the "Thank You"
Let>body=This is the copy of your ads submitted to The HC on %date%%CRLF%If you have any question, please contact your representative.%CRLF%%CRLF%Thank you
SMTPSendMail>recipients,mailhost.chron.com,me,myname,subject,body,attachments
Message>Result of SendMail: %SMTP_RESULT%
Label>end
Problem 1 was because you had the send-the-email part after the "Label>end", so your script would jump to that if there were 0 files found, and then still exceute the rest of the script.
Problem 2... don't know, it worked for me. Perhaps you didn't have all the "let>body" stuff on one line.
You also didn't need the k=k+1 loop. You can probably get away with using "seperate" too, and check the length of "%files%" instead, but I kept it close to how you had it so you could still see how it worked.
Re: Thank you
Mine does. Maybe it's the browser you're viewing the email with. (Especially if it's non-windows).tleary wrote:The double %CRLF%%CRLF% works but the single one %CRLF% does not give me a line break.
Right now, you are testing either "any files found" by running "seperate" command, then reading the value of %file_names_count%.tleary wrote: And what do you mean by " and check the length of "%files%" instead "
If instead, your value of %files% is blank, you will also know that no files were found.
(To Guest: CountFiles won't work as effeciently in this instance, because you are looking to obtain the filenames too so you can attach them.)