Need help with email program
[1/2] from: mechtn::tkweb::net at: 12-Nov-2001 11:05
hey, i'm making a program to automatically check my inbox for remove's or unsubscribe's
for my mailing list.. here is the code i am working with and it errors out almost everytime.
some times it works ok but very rarely.. it gets an error saying ...
connecting to: mail.tkweb.net
** Script Error: find expected series argument of type: series port bitset
** Where: forall
** Near: if find mail/subject word [
print ["Found in:" mail/from mail/subject]
write/append %/C/rebol/remove.txt mail/from
write/append %/C/rebol/remove.txt ","
inbox: remove inbox
break
]
>>
now this one basically checks the subject for any of the words from the word-list, i
have another one that checks the content and it works fine.. the code is exactly the
same except the if find state has mail/content instead of mail/subject. i dont know why
the one with subject acts up. Can anyone please help me! Thanks..
REBOL [
Title: "Email Sniffer"
File: %mailsniff.r
Date: 10-Sep-1999
Purpose: {
Example of how to search all incoming email for
particular keywords.
}
Note: {
Does not remove the mail from the server.
Any string (word) may be given, even partial words.
Strings (words) are not case sensitive.
FOREACH returns a value, just like other functions.
}
Category: [email net 2]
]
word-list: ["remove" "unsubscribe" "REMOVE" "Remove" "REMOVE!"]
inbox: open load %popspec.r ;file contains POP email box info
forall inbox [
mail: import-email first inbox
foreach word word-list [
if find mail/subject word [
print ["Found in:" mail/from mail/subject]
write/append %/C/rebol/remove.txt mail/from
write/append %/C/rebol/remove.txt ","
inbox: remove inbox
break
]
]
]
close inbox
-------
Koie Smith
[2/2] from: ingo:2b1 at: 12-Nov-2001 20:36
Hi Koie,
Once upon a time mechtn spoketh thus:
<...>
> connecting to: mail.tkweb.net
> ** Script Error: find expected series argument of type: series port bitset
<<quoted lines omitted: 6>>
> break
> ]
OK, let's walk throufg it step by step:
The error states, that find is expecting a series (...) but didn't
get one, now where can this be? 'word should be correctly set, and
from your post I conclude, it's unchanged from the other version.
So, we'll have to inspect 'mail/subject, this is the subject, of
the imported email. How could this be not a series?
Let's have a look into import-email:
>> probe import-email {from: me
{
{ hi
{ }
make object! [
To: none
CC: none
BCC: [ingo--2b1--de]
From: [me]
Reply-To: none
Date: none
Subject: none
Return-Path: none
Organization: none
Message-Id: none
Comment: none
X-REBOL: "1.2.1.4.2 http://WWW.REBOL.COM"
MIME-Version: none
Content-Type: none
Content: "hi^/"
]
>>
Got it? If the subject isn't set in the email, the email object
contains 'none, instead of a string, and find can't handle this.
<...>
> forall inbox [
> mail: import-email first inbox
> foreach word word-list [
> if find mail/subject word [
; change this line to
if all [ not none? mail/subject find mail/subject word] [
; now the find will only be run, when the subject is not equal to 'none.
> print ["Found in:" mail/from mail/subject]
> write/append %/C/rebol/remove.txt mail/from
<<quoted lines omitted: 4>>
> ]
> ]
I hope that clarifies it a bit,
Ingo
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted