I need the expert to look at this code

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

I need the expert to look at this code

Post by timle » Mon Jan 24, 2005 5:27 pm

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%

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Mon Jan 24, 2005 5:40 pm

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.

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Thank you

Post by timle » Mon Jan 24, 2005 6:00 pm

Thank you Captive

The double %CRLF%%CRLF% works but the single one %CRLF% does not give me a line break.

And what do you mean by " and check the length of "%files%" instead "

Thanks

Guest

Post by Guest » Mon Jan 24, 2005 7:11 pm

I used "countfiles" and it works great too

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Re: Thank you

Post by Captive » Mon Jan 24, 2005 8:41 pm

tleary wrote:The double %CRLF%%CRLF% works but the single one %CRLF% does not give me a line break.
Mine does. Maybe it's the browser you're viewing the email with. (Especially if it's non-windows).
tleary wrote: And what do you mean by " and check the length of "%files%" instead "
Right now, you are testing either "any files found" by running "seperate" command, then reading the value of %file_names_count%.

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.)

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts