Advertisement

02.15.2008 at 07:58PM PST, ID: 23167937
[x]
Attachment Details

Tcl syntax

Asked by ddantes in TCL Scripting Language

I am using an Outlook add on program called Email Templates in order to create automated responses to forms which are submitted via Email from a website.  Below is a sample form.  I must create a template which will be used in the automated response message. I would appreciate the TCl syntax for extracting the First Name, to be used in the salutation of the reply.  The recipient's Email address (but not the other Email addresses in the form) needs to be placed in the recipient field of the reply.  
Thank you...

The following consumer,Kelley<krjust28@hotmail.com> is interested in Adventure in Paradise's Romance Offer and would like more information from your company.  Please send them more information on how to receive your special offer. Please note the from address is now set to membership@hvcb.org to prevent spam blockers from blocking certain email addressess in the 'From:' field.  The Reply-To field has been set to the user's email so that you can simply reply to this message to send your information.

Mahalo!

First Name: Kelley
Last Name: Jones

Address 1: 12001 Market Street, Apt. T-41

Address 2:
Reston,VA  20190  United States

Email: krjust28@hotmail.com

Phone:

Requests: Romance Information

Start date of visit: 2009-05-01
End date of visit: 2009-07-01

Been to Hawaii?:
# Adults: 2
# Children: 0
Islands of Interest: Oahu,Kauai,Maui,

Comments: We are not sure what our budget is at this time- researching to see if Hawaii will be affordable.  I am interested in knowing which Island has adventure ( volcanoes, exploring)
Primary purpose of your trip: Honeymoon

Are you planning to hold a wedding/renewal ceremony in Hawaii?No:K,Ma,H,

What islands are you considering for your ceremony?

What is your budget: Wed: Ren:8-10k?

Start Free Trial
[+][-]02.16.2008 at 01:29AM PST, ID: 20908977

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 11:47AM PST, ID: 20911103

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.18.2008 at 10:37PM PST, ID: 20926221

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.18.2008 at 11:43PM PST, ID: 20926411

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 01:02AM PST, ID: 20926722

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 01:23PM PST, ID: 20932744

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 11:23PM PST, ID: 20935697

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: TCL Scripting Language
Sign Up Now!
Solution Provided By: fridom
Participating Experts: 2
Solution Grade: B
 
 
[+][-]02.20.2008 at 04:58PM PST, ID: 20943975

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.20.2008 at 10:42PM PST, ID: 20945518

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 10:26AM PST, ID: 20950415

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 08:03PM PST, ID: 20954478

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 10:33PM PST, ID: 20955124

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 10:46PM PST, ID: 20955169

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2008 at 10:32PM PST, ID: 20963897

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2008 at 10:32PM PST, ID: 21001619

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.16.2008 at 01:29AM PST, ID: 20908977
I just saved away this:
Mahalo!

First Name: Kelley
Last Name: Jones

Then I run this script to extract the first name:
proc find_first_name {line} {
    set first_name ""
    #puts $line
    set i [regexp -expanded {First\s+Name:\s+([[:alpha:]]+)} $line match first_name]
    # puts "i = $i\n"
    return $first_name

}


set file [open "mail_text.txt" r]

set found ""
while { [gets $file line] >= 0 && $found == ""} {
    # puts $line
    set found [ find_first_name $line ]
}

if {$found != ""} {
    puts "found: $found"
}

close $file


Output:
     tclsh mail_text.tcl
found: Kelley


This should give you an idea

Regards
Friedrich




 
02.16.2008 at 11:47AM PST, ID: 20911103
Aloha Friedrich:
Thank you for your comment.  I pasted the suggested script into a template and tested it, but it did not return the variables.  Below is a script which "almost" works.  It finds every Email address in the form and includes them all in the recipient field, instead of just the single Email address which appears after "Email:"  in the form.  It also produces an incorrect reply salutation incorrectly as

Aloha Kelley
Aloha Last:  

instead of Aloha Kelley:
Here is the almost-successful script...

<et>
set InMail [et message body]
regexp {Name: ([^ ]+)} $InMail match First_Name
set First_Name [string trim $First_Name]
et add First_Name $First_Name

set text [et message body]
set text [split $text " \n\r,()\t:;\"*<>+^&%'"]
foreach word $text {
if [string match *?@?* $word] {
et set recipient [string trim $word ".\]\[\}\{()"]
et set subject "Honeymoon on Maui"
}
}
</et>
<et>
Aloha &First_Name;:  
 
02.18.2008 at 10:37PM PST, ID: 20926221
You have some fault in the regular expression.
Check what you are looking for to get the Last Name you should look for the full name.
 
As you can see my code give back the name properly

Regards
Friedrich
 
02.18.2008 at 11:43PM PST, ID: 20926411
Dear Friedrich:

Thank you for your comment.  The script is almost working now.  The following script returns the First Name correctly, and it finds the one Email address which belongs in the recipient field.  However,
in the recipient field there are characters added to the Email address, ending with "phone" -- which should not appear there.  Can you advise how to eliminate the extra characters following the Email address?

<et>
set InMail [et message body]
regexp {Name: ([^ ]+)} $InMail match First_Name
set First_Name [string trim $First_Name]
et add First_Name $First_Name

set InMail [et message body]
regexp {Email: ([^ ]+)} $InMail match Email
set Email [string trim $Email]
et add Email $Email
et set recipient $Email

et set subject "Honeymoon on Maui"

</et>
<et>

Aloha &First_Name;:  

 
02.19.2008 at 01:02AM PST, ID: 20926722
It seems the match [^ ] looks for the next whitespace. I don't know why phone will added otherwise for me it seems that the \n is ignore which would be ok IMHO because \n is not a blank. But you can check our very easily yourself. Play with the regexp. I would try
{Email:\s+([^ ]+)$} first ....
Then I would look to escape sequences which match on the beginniing or end of words.

Regards
Friedrich
 
02.19.2008 at 01:23PM PST, ID: 20932744
Hi Friedrich:

Unfortunately I am not trained in Tcl or regular expression syntax.  I have played with the regexp, but it is just trial and error.  So far, only error!
 
02.19.2008 at 11:23PM PST, ID: 20935697
then you have to look it up I posted what you should look for and a bit looking through the docs reveils one has to use the -lineanchor flag so the expression to match the email is:
 regexp -line {Email:\s+(.+)$} $line match email

or if you like
regexp -line {Email:\s+([^ ]+)$} $line match email

Regards
Friedrich
Accepted Solution
 
02.20.2008 at 04:58PM PST, ID: 20943975
Friedrich:

    Thank you for your suggestions.  Both scripts returned an error "can't read  'line' -- no such variable."
Just now, someone from another site contributed the following script, which resolved the problem.  It apparently searches for the variable while ignoring not only whitespace,  but also carriage returns and newlines...
regexp {Email: ([^ \r\n]+)} $InMail match Email

    I appreciate your offer of assistance!
David

 
02.20.2008 at 10:42PM PST, ID: 20945518
Well line was just an example for the string to be searched and no it works perfectly, you'd just had to replace $line with $InMail that's not asked too much.

It just shows that you did not even bother to understand the code. That hardly can be my fault

Here's a tclsh session showing how fine that works:
% set line "Email: abc@def.com\nPhone:"
Email: abc@def.com
Phone:
% regexp -line {Email:\s+([^ ]+)$} $line match email
1
% set email
abc@def.com
%

The code send just taked into account the normal regexp rules. But you did not even have looked at them and what they mean.

So no I do object.

Friedrich
 
02.21.2008 at 10:26AM PST, ID: 20950415
Hi Friedrich:

    Thank you for your comments.  You are correct that I do not understand the code.  That is the reason I requested assistance from an expert.   Sorry you are dissatisfied, so let's  leave it up to a moderator to resolve whether you will receive points for your proposed solution.

Thanks,
David
 
02.21.2008 at 08:03PM PST, ID: 20954478
A request has been made in Community Support to close this question:
http://www.experts-exchange.com/Q_23180274.html

If there are no objections, a moderator will finalize this question in approximately 4 days as follows:
Delete with refund

Please leave any recommendations here.

Computer101
EE Admin
 
02.21.2008 at 10:33PM PST, ID: 20955124
Well you have not lookied up the parameters of regexp and and the only change needed was matching the proper string , as one can see the last posting chooses exactly what parameter goes where. So the solution is correct the only thing was matching against a proper variable. I do not agree with the delete. The questoin was answered correctly

Regards
Friedrich
 
02.21.2008 at 10:46PM PST, ID: 20955169
Another comment. You have used my suggestion in your solution and are still asking for  a deletion of points. Is is just me who thinks something is wrong with that? I reported that.

Friedrich
 
02.22.2008 at 10:32PM PST, ID: 20963897
I asked for the question to be closed because it was solved without the expert's assistance.
Here are the scripts which the expert recommended:
regexp {Email:\s+([^ ]+)$}   (result:  "wrong number of arguments in embedded script")
regexp -line {Email:\s+(.+)$} $line match Email  (result: "can't read 'line' -- no such variable")
regexp -line {Email:\s+([^ ]+)$} $line match Email  (result: "can't read 'line' -- no such variable")
Unfortunately, none of them worked.
Here is a script contributed by someone outside of Expert's Exchange, and it worked:
regexp {Email: ([^ \r\n]+)} $InMail match Email
After sharing the successful script with the expert, he commented that I should have known enough to substitute "$InMatch" for "$line" in his recommendation.   I couldn't have known enough to make that substitution because I am not a programmer.  Had I known enough to make that substitution, I probably would have known how to write the script myself.
 I am not trying to deprive the expert of credit.  However, he did not solve the problem.  Whatever the moderator decides if fine with me.

 
02.27.2008 at 10:32PM PST, ID: 21001619
Well you still have based the solution on my suggestions. And that one can not replace one variable name with another is well "unusual" the section is about programming. You were abel to modify my script to use your variable so I can expect that you can it the other way round also.

Regards
Friedrich
 
 
03.02.2008 at 01:30PM PST, ID: 21027679
Force-accepted to close.

Netminder
Site Admin
 
 
 
20080716-EE-VQP-32 / EE_QW_2_20070628