[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Retrieving EMAil Address

Retrieving EMAil Address

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Retrieving EMAil Address

Postby gavinjb » Mon Apr 24, 2006 7:09 am

Hi,

Does anyone know an easy way of retrieving the EMail Address, as if I try to retrieve the Address from the "From" of the Header I mor e often than not end up with:

Name <name@me.com>

And all I want to be able to retrieve is the name@me.com

Thanks,


Gavin,
gavinjb
Frequent Visitor
 
Posts: 56
Joined: Mon Jan 24, 2005 11:41 pm
Location: Reading, UK

Postby MarkB » Mon Apr 24, 2006 11:48 am

Try Extractmail.
Code: Select all
Set $a "John Doe <jd@thedoes.org>"
ExtractEmail $a
MessageBox $a

I'll be interested to see if you reply this time.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby gavinjb » Tue Apr 25, 2006 12:48 am

Thanks for the code, unfortunately that is what I am already doing

Code: Select all
ReadHeader $header "From" %message
ExtractEmail $header
MessageBox $header


Thanks,


Gavin
gavinjb
Frequent Visitor
 
Posts: 56
Joined: Mon Jan 24, 2005 11:41 pm
Location: Reading, UK

Postby MarkB » Tue Apr 25, 2006 12:54 am

Your code is working fine here.

Edit: with v 3.4.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby Michael » Tue Apr 25, 2006 2:49 am

Ok here as well (build 3650).
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby gavinjb » Tue Apr 25, 2006 7:05 am

I have just tried it on my Classification script (have realized that there are occasions where I need to look for EMails in my text files rather than the address books)

Code: Select all
{### classify_email }

{ Script will scan a message and add to message header }
{ X-Text-Classification: {classification Type found }

{Please note this script has only been tested on Barca 2 }

{ Usage: could be used manually or on incoming mail; }
{            when used manually, just select all messages }

External $userdata1 "Please Enter path of Domain Files:" "C:\Documents and Settings\Gavin\My Documents\EMail\Barca\Scripts\Classify\"

{ Get address from Reply-To header }
ReadHeader $email "Reply-To" %message

{ If there is no Reply-To header, get address from From header }
if $email = "" then GetFrom

GoTo ProcessAddress

:GetFrom
ReadHeader $email "From" %message

:ProcessAddress
{ need to check each of the filter text files to see if domain is in there }
{ and addressbooks for friends and work }
ExtractEMail $From

Set $Type "work"
Call CheckClassification
{If &Found Then Leave

Set $Type "friends"
Call CheckClassification
{If &Found Then Leave

Set $Type "accounts"
Call CheckClassification
{If &Found Then Leave

Set $Type "banking"
Call CheckClassification
{If &Found Then Leave

Set $Type "newsletters"
Call CheckClassification
{If &Found Then Leave

Set $Type "orders"
Call CheckClassification
{If &Found Then Leave

Set $Type "photography"
Call CheckClassification
{If &Found Then Leave

{ None found so set to other }
Set $Type "other"
Call Classify

:Leave
Exit

:CheckClassification
Set $AddressBook $Type
If $Type ! "Friends" Then CheckBook
Set $AddressBook "Address"

{  Check address book for presence of address }

:CheckAddressBook
IsAddressPresent &present $email $AddressBook
if &present then Classify

:CheckDomainFiles
{  Check text file for domain }

{  extract domain name }
ReadHeader $Domain "From" %message
ExtractEmail $Domain
ReadHeader $EMail "From" %message

stringpos #a "@" $Domain
chopstring $Domain 1 #a

{  Probably call as an external subroutine. }
{  Return result in variable $Domain }

Set $File $userdata1
AddStrings $File $Type ".txt"

{ check for email addresses }
OpenBody $EMails $File
LowerCase $EMails
LowerCase $EMail
LinePos #ix $EMail $EMails
messagebox "EMail"
messagebox $EMail
If #ix > -1 then Classify

{ Check domains }
OpenBody $Domains $File
LowerCase $Domains
LowerCase $Domain
LinePos #ix $Domain $Domains

If #ix > -1 then Classify
Return

:CheckBook
Set $AddressBook $Type
Call CheckAddressBook
Return

:Classify
AddHeader %message "X-Text-Classification:" $Type
Call Leave


but when I run this everytime it see the email addresses as name <name@domain.com>

I do have the expand_from_names script running, but I tried disabling htis and I still get the same.
gavinjb
Frequent Visitor
 
Posts: 56
Joined: Mon Jan 24, 2005 11:41 pm
Location: Reading, UK

Postby MarkB » Tue Apr 25, 2006 7:55 am

Which variable are we to look at? I see two ExtractEmail commands. The first one acts on an apparently empty variable, $From, which we never hear from again. The second acts on the variable $Domain. Yet the message boxes suggest that you are looking for the extracted addresses in $Email.

Quote:
ReadHeader $email "Reply-To" %message
ReadHeader $email "From" %message
ExtractEMail $From [The variable is undefined at this point]
ReadHeader $Domain "From" %message
ExtractEmail $Domain
ReadHeader $EMail "From" %message
messagebox "EMail"
messagebox $EMail
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby gavinjb » Tue Apr 25, 2006 8:12 am

Sorry, the issue seems to be with the $EMail one, as the $Domain works fine.
gavinjb
Frequent Visitor
 
Posts: 56
Joined: Mon Jan 24, 2005 11:41 pm
Location: Reading, UK

Postby MarkB » Tue Apr 25, 2006 8:26 am

And there is no line like ExtractEmail $EMail in your script.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby gavinjb » Tue Apr 25, 2006 10:10 am

Your right, I could have sworn that I had put ExtractEMail in, I even missed it when I re-checked the script. Anyway I have added it and it is working fine now, thanks for the help.
gavinjb
Frequent Visitor
 
Posts: 56
Joined: Mon Jan 24, 2005 11:41 pm
Location: Reading, UK


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 2 guests

cron