• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Splitting up email addresses by comma's

Explorer ,
Jan 29, 2007 Jan 29, 2007

Copy link to clipboard

Copied

I am trying to input info into a database and I have a mailer form above it that supports multiple addresses. Someone suggested the trim option used below to seperate each line with info however that doesn't work. I wish to use all the same info in teh database entry however only put 1 email address per entry even if 5 are used.
TOPICS
Advanced techniques

Views

222

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 29, 2007 Jan 29, 2007

Copy link to clipboard

Copied

LATEST
if i understand you correctly, you want to insert only ONE email address into your db, even if the entry field contains several comma-separated emails? do not <cfloop> through the for.recipiants list then. instead use, for example, '#ListFirst(form.recipiants)#' instead of '#trim(thisAddress)#' in your INSERT query.

however, if what you want to do is insert A SEPARATE RECORD for EACH EMAIL ADDRESS in the list, then you have to do something like (NOTE: i am assuming form.email is a comma-delimited list of recepients and form.recipiants is a comma-delimeted list of their names):
<cfloop index="iii" from="1" to="#ListLen(form.recipiants)#">
<cfquery name="updatetable" datasource="#------#">
INSERT INTO send_to_friend (email, receivers_name, sendersname, sendersemail, message)
VALUES ('#ListGetAt(form.email, iii)#', '#ListGetAt(form.recipiants, iii)#', '#form.sendersname#', '#form.sendersemail#', '#form.message#')
</cfquery>
</cfloop>

IMPORTANT: you will have to implement some serious validation here to check that the lists of emails/names have more than one item and that number of items in both lists match!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation