Link to home
Start Free TrialLog in
Avatar of tomhwtt
tomhwtt

asked on

Coldfusion, CFPOP , To & From Fields.

Hi..

I am retrieving emails using CFPOP.

When it returns the "To" and "From" fields I want it to just be the email address so I can setup a reply action.

Right now I get:

to:<margesimpson@thesimpsons.com>
from:"Homer Simpson" <homersimpson@thesimpsons.com>

How can I make sure it returns just the email address instead?  ...or can I strip the stuff I don't need?

Can I just remove all characters before and after <  &  >   ??

The code is below.

Thank you for any assistance!

Tom



<cfpop action="getall" name="getMessage" server="myserver" username="myusername" password="mypassword" port="port>
 
<cfscript>
function pformat(str)
{
str = replace(str,chr(13)&chr(10),chr(10),"ALL");
str = replace(str,chr(13),chr(10),"ALL");
str = replace(str,chr(9),"&nbsp;&nbsp;&nbsp;","ALL");
return replace(str,chr(10),"<br>","ALL");
}
</cfscript>
 
 
<cfoutput query="getMessage">
to:#HTMLEditFormat(getMessage.to)#<br>
from:#HTMLEditFormat(getMessage.from)#<br>
UID:#HTMLEditFormat(getMessage.uid)#<br>
subject:#HTMLEditFormat(getMessage.subject)#<br><br>
BODY:<br><br>
#pformat(getMessage.body)#
 
</cfoutput>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tomhwtt
tomhwtt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Coast Line
What are you trying to do here:

My Assumption:

1.You can use the reply parameter of the Coldfusion Cfmail tag and add the email address which you want to if it is dynamic you can adf the from value in the reply link. Whenever the user clicks the reply button it will send the email to the emailAddress specified by you in the cfmail reply parameter. The email will go no matter if it full address like the same you have in the FROM value.

Glad you made it work and now i understood what exactly you were trying to do:

You can also use the rereplace functionality to get only email address
Avatar of tomhwtt
tomhwtt

ASKER

Thanks, myselfrandhawa:..

I cleaned it up a little more today.  Not sure what I was thinking last night...I just needed to rest my brain maybe :)

Cleaned up code below.  I am going to try rereplace as you suggest as well. Thanks again.

Tom
<cfset startFrom = listFirst(#getMessage.from#,'<')>
<cfset endFrom = listFirst(#getMessage.from#,'>')>
 
<cfset startNum = (#len(startFrom)#) + 1>
<cfset endNum = #len(endFrom)# - #len(startFrom)#>
 
<cfset startChar = removechars(#getMessage.from#,1,#startNum#)>
<cfset endChar = removeChars(#startChar#,#endNum#,1)>
 
<cfset emailAddress = #trim(endChar)#><!---just email address--->

Open in new window