Creating A Dymanic CFMAIL Tag

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Creating A Dymanic CFMAIL Tag

    I am creating an automatic email system for several clients; some which have an
    e-mail server we can use and some that requires a username and passord.

    I am trying to figure out the best way to develop a cfmail tag which is
    custimized to their email server settings, since we can not use cfif or the
    #if# item inside the cfmail tag itself. I have posted what I am trying to
    accomplish with cfmail and cfif.

    Is there a better way to do this rather than writing several cfmail tags with
    different cfif senarios?

    Thanks! Jeremy

    <cfquery name="getemailserverinfo" datasource="#ds#">
    SELECT client_emailserver_server, client_emailserver_port,
    client_emailserver_timeout, client_emailserver_username,
    client_emailserver_password, client_emailserver_mailerid
    FROM client_emailserver
    WHERE webbase_id = <cfqueryparam cfsqltype="cf_sql_integer"
    value="#webbase_id#">
    </cfquery>

    <cfmail
    <cfif getmailserverinfo.recordcount is not 0>
    <cfif trim(getmailserverinfo.client_emailserver_server) is not ''>
    server="#trim(getmailserverinfo.client_emailserver _server)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_port) is not ''>
    port="#trim(getmailserverinfo.client_emailserver_p ort)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_timeout) is not ''>
    timeout="#trim(getmailserverinfo.client_emailserve r_timeout)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_username ) is not ''>
    username="#trim(getmailserverinfo.client_emailserv er_username)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_password ) is not ''>
    password="#trim(getmailserverinfo.client_emailserv er_password)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_mailerid ) is not ''>
    mailerid="#trim(getmailserverinfo.client_emailserv er_mailerid)#"
    </cfif>
    </cfif>
    query="grab_webbaseusers" type="html" to="""#trim(webbaseuser_firstname)#
    #trim(webbaseuser_lastname)#"" <#trim(webbaseuser_email)#>"
    from="""#trim(getclientemailinfo.client_name)#""
    <#trim(getclientemailinfo.recentchanges_emailaddre ss)#>"
    subject="#trim(form.emailsubject)#">
    #form.emailmessage#
    <br><br>
    #cfhttp.FileContent#

    </cfmail>

    JBishop Guest

  2. Similar Questions and Discussions

    1. New to Dymanic Pages/ User Login/Poll
      Hi ! I have never designed a dynamic page before (only static pages) and I'm really confused as to how to go about it ! I'm designing a web page...
    2. Dymanic Query and CFIF Problems
      Problem: I have an application where I have one access table with the following fields: autonum, cca_index, cca_category, wt_index, wt_category. ...
    3. cfmail - Attribute validation error for tag CFMAIL.
      I'm getting the error ' Attribute validation error for tag CFMAIL.' on the code below. All its doing is outputting a text string to the TO: field. ...
    4. Panel and dymanic table
      On a run time I am generating a table inside a panel. The table alsways generated to the left and I wanted to be in canter of the panel. How do I...
    5. Dymanic load
      Hi im am trying to build a menu. and i wont to load files into this menu dynamic. As base i use Term_ANSIMenu-0.02 This module builds a meny from...
  3. #2

    Default Creating A Dymanic CFMAIL Tag

    I am creating an automatic email system for several clients; some which have an
    e-mail server we can use and some that requires a username and passord.

    I am trying to figure out the best way to develop a cfmail tag which is
    custimized to their email server settings, since we can not use cfif or the
    #if# item inside the cfmail tag itself. I have posted what I am trying to
    accomplish with cfmail and cfif.

    Is there a better way to do this rather than writing several cfmail tags with
    different cfif senarios?

    Thanks! Jeremy

    <cfquery name="getemailserverinfo" datasource="#ds#">
    SELECT client_emailserver_server, client_emailserver_port,
    client_emailserver_timeout, client_emailserver_username,
    client_emailserver_password, client_emailserver_mailerid
    FROM client_emailserver
    WHERE webbase_id = <cfqueryparam cfsqltype="cf_sql_integer"
    value="#webbase_id#">
    </cfquery>

    <cfmail
    <cfif getmailserverinfo.recordcount is not 0>
    <cfif trim(getmailserverinfo.client_emailserver_server) is not ''>
    server="#trim(getmailserverinfo.client_emailserver _server)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_port) is not ''>
    port="#trim(getmailserverinfo.client_emailserver_p ort)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_timeout) is not ''>
    timeout="#trim(getmailserverinfo.client_emailserve r_timeout)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_username ) is not ''>
    username="#trim(getmailserverinfo.client_emailserv er_username)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_password ) is not ''>
    password="#trim(getmailserverinfo.client_emailserv er_password)#"
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_mailerid ) is not ''>
    mailerid="#trim(getmailserverinfo.client_emailserv er_mailerid)#"
    </cfif>
    </cfif>
    query="grab_webbaseusers" type="html" to="""#trim(webbaseuser_firstname)#
    #trim(webbaseuser_lastname)#"" <#trim(webbaseuser_email)#>"
    from="""#trim(getclientemailinfo.client_name)#""
    <#trim(getclientemailinfo.recentchanges_emailaddre ss)#>"
    subject="#trim(form.emailsubject)#">
    #form.emailmessage#
    <br><br>
    #cfhttp.FileContent#

    </cfmail>

    JBishop Guest

  4. #3

    Default Re: Creating A Dymanic CFMAIL Tag

    maybe not the most efficient but I would probably do it like this:

    <cfquery name="getemailserverinfo" datasource="#ds#">
    SELECT client_emailserver_server, client_emailserver_port,
    client_emailserver_timeout, client_emailserver_username,
    client_emailserver_password, client_emailserver_mailerid
    FROM client_emailserver
    WHERE webbase_id = <cfqueryparam cfsqltype="cf_sql_integer"
    value="#webbase_id#">
    </cfquery>

    <cfif getmailserverinfo.recordcount is not 0>
    <cfif trim(getmailserverinfo.client_emailserver_server) is not ''>
    <cfset server = #trim(getmailserverinfo.client_emailserver_server) #>
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_port) is not ''>
    <cfset port = #trim(getmailserverinfo.client_emailserver_port)#>
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_timeout) is not ''>
    <cfset timeout = #trim(getmailserverinfo.client_emailserver_timeout )#>
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_username ) is not ''>
    <cfset username = #trim(getmailserverinfo.client_emailserver_usernam e)#>
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_password ) is not ''>
    <cfset password = #trim(getmailserverinfo.client_emailserver_passwor d)#>
    </cfif>
    <cfif trim(getmailserverinfo.client_emailserver_mailerid ) is not ''>
    <cfset mailerid = #trim(getmailserverinfo.client_emailserver_maileri d)#>
    </cfif>


    <cfmail server="#server#" port="#port#" timeout="#timeout#"
    username="#username#" password="#password#" mailerid="#mailerid#"
    query="grab_webbaseusers" type="html" to="""#trim(webbaseuser_firstname)#
    #trim(webbaseuser_lastname)#"" <#trim(webbaseuser_email)#>"
    from="""#trim(getclientemailinfo.client_name)#""
    <#trim(getclientemailinfo.recentchanges_emailaddre ss)#>"
    subject="#trim(form.emailsubject)#">
    #form.emailmessage#
    <br><br>
    #cfhttp.FileContent#

    </cfmail>
    <cfelse>


    <cfmail query="grab_webbaseusers" type="html"
    to="""#trim(webbaseuser_firstname)# #trim(webbaseuser_lastname)#""
    <#trim(webbaseuser_email)#>" from="""#trim(getclientemailinfo.client_name)#""
    <#trim(getclientemailinfo.recentchanges_emailaddre ss)#>"
    subject="#trim(form.emailsubject)#">
    #form.emailmessage#
    <br><br>
    #cfhttp.FileContent#

    </cfmail>
    </cfif>

    futureman Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139