EasyCFM.COM ColdFusion Forums / Coding Help! / Schedule Emails

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Schedule Emails -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

5h4rk
07-02-2007 @ 5:22 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Jul 2007

Hi all! I'm new -started yesterday- in Coldfusion, I've been reading for a while, and found it to be a very intuitive and easy language to learn. One of the feature that I found quite interesting is <CFMAIL>.

What I want is trigger an email every 4 weeks with the latest news of a webpage. The news are from a DB.

The question is, what is the best way to do it?

I appreciate your help
Thanks.

specific
07-02-2007 @ 6:51 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

The Cfschedule tag will work what you need to do?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

5h4rk
07-02-2007 @ 7:01 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Jul 2007

I want to send an email every 4 week -as a newsletter-.

How can I do that? Should I use SQL to manage the "4 weeks" or use CF?

How? :D

Thanks.

nmiller
07-02-2007 @ 10:18 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 773
Joined: Apr 2003

create a database field that stores the last time the newsletter was sent.  Then create a scheduled task to run every day, and add logic that first checks the last sent date.  if the datediff between now() and the db date is 4 weeks, sent the message, otherwise do nothing.

Nathan Miller
NM Consulting

5h4rk
07-02-2007 @ 10:27 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Jul 2007

Thanks! Can you be more specific please? As I'm new on this Frown  Maybe some code?

Anyway, I'll try to do what you said.

Thanks!

Webmaster
07-02-2007 @ 2:15 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

I think you need to take a step back and first learn how to interact with databases to retrieve the data... once you have that you can start looking into cfschedule and cfmail.

I know that a lot of times people will have in mind what they want and use it as a learning solution; however what you are wanting to do would be like me giving you the keys to a ferrari when you have never driven before.

You need to go learn the basics (the beginner) items and then from there apply it to the techniques and needs you have.

I can almost guarantee that you will not get code; because that defeats the purpose of you learning (which is what this site is about... not abour people writing code for you).

There are about 100 beginner tutorials on the tutorials section of this site that should get you started; from there you've been given direction on what to do to accomplish your task.. you need to take a step back an try to do it yourself... and if you get stuck come for help... Not saying we don't want to help (because we do) but we are here to help you; not do it for you! Smile

that being said; check out the tutorials.. there is a lot there you can use to learn how to do what you need to do!

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

5h4rk
07-02-2007 @ 9:52 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Jul 2007

Yes, that I've been trying to do, thanks for the advise Wink

MESSAGE DELETED

quote:


<cfmail query="qNews"

  from="xxxxx@xxxx"
  to="xxxxx@xxxxx"
  type="html"
  subject="TEST">

<a href="xxxxxx">#replace(replace(qNews.title, "&", "&", "All"),"&", "&", "All")#</a> #dateFormat(startDate, "d mmm, yyyy")#<br/>
#replace(replace(qNews.summary, "&", "&", "All"),"&", "&", "All")#
    
</cfmail>



The email(s) is sent successfully, but, instead of 1 email of 20 news, I get 20 emails for each news. How can I stop the loop and put everything into one mail?

Thanks.

This message was edited by 5h4rk on 7-2-07 @ 11:30 PM

dlackey
07-03-2007 @ 9:29 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 935
Joined: Jun 2007

Are you scoping your variables?  
obviously your are blanking out your From and To fields but be sure to scope your variables.

For Example:
<cfmail query="qNews"

  from="#qNews.FromField#"
  to="#qNews.ToField#"
  type="html"
  subject="TEST">

<a href="#qNews.urlLink#">#replace(replace(qNews.title, "&", "&", "All"),"&", "&", "All")#</a> #dateFormat(startDate, "d mmm, yyyy")#<br/>
#replace(replace(qNews.summary, "&", "&", "All"),"&", "&", "All")#
    
</cfmail>



Cheers,
Chip

This message was edited by dlackey on 7-3-07 @ 3:18 PM

nmiller
07-03-2007 @ 10:35 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 773
Joined: Apr 2003

You probably want to group by email address.  lookup grouped output in a cfoutput query on this forum and google.

search for 'cfoutput query group'

Nathan Miller
NM Consulting

Webmaster
07-03-2007 @ 12:42 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

You can group as mentioned; or you can generate the email body inside of a CFSAVECONTENT tag; then put that value in the email... sample:

<cfoutput>
<cfsavecontent variable="emailContent">
<cfloop query="qNews">
   <!--- do your loops here --->
   <a href="xxxxxx">#replace(replace(qNews.title, "&", "&", "All"),"&", "&", "All")#</a> #dateFormat(startDate, "d mmm, yyyy")#<br/>
#replace(replace(qNews.summary, "&", "&", "All"),"&", "&", "All")#
</cfloop>
</cfsavecontent>
<cfoutput>

cfmail from="xxxxx@xxxx"
  to="xxxxx@xxxxx"
  type="html"
  subject="TEST">

   #emailContent#    

</cfmail>

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

PAGE: 1 2

Website Designed and Developed by Pablo Varando.