Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

trouble with removing email headers...

Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-25-2006 14:39
Hello, I have been playing with the sample email script available on the WIKI, but I have ran into a snag with removing the header information. I can remove it, but I am also losing the first leter of the message. I have played with this number (message, "\n\n";) +1); <----- and can remove more than the first, but I can't seem to find the right combo to bring it back.

Help! :eek:

CODE

key rlemail="you@nyob.com";

default {
state_entry()

{
llEmail(rlemail, "SLEmail Server address", (string)llGetKey() + "@lsl.secondlife.com"); // send email to self

llSetTimerEvent(2.5); // poll for emails (yes, that is a retarded way on an event-based system)
}

timer()
{
llGetNextEmail("", "cmd"); // check for email with any subject/sender
}

email(string time, string address, string subj, string message, integer num_left)
{
string MessageWithoutHeaders = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") +1);

llSay(0, MessageWithoutHeaders);
//llSay(0, "You've got mail! \n Time: " + time +"\n Address: " + address + "\n Subject: " + subj + "\n Body: " + message + "\n You have " + (string)num_left + " email/s left.");

}

}
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
02-25-2006 15:44
I'd try knocking off the +1 after /n/n, that should work.
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-25-2006 15:53
Thanks Eloise.

Thought that also... it makes it blank or removes the whole message.

I email: Hello there!

I get-

object: ello there! <--- with +1
object: llo there! <--- with +2
object: <--- with +0
object: <--- +1 removed


From: Eloise Pasteur
I'd try knocking off the +1 after /n/n, that should work.
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
02-25-2006 18:19
The "headers" which that snippet refers to are the four lines that llEmail() inserts into the body of outgoing emails containing the object name, region, and position. It sounds like are getting those confused with normal email headers. If you are sending an email to your object from outside of SL, it will not have those headers inserted into the body of the email, so you don't need to remove them.

What's happening is: llSubStringIndex(message, "\n\n";); is returning -1 since there aren't two newlines in a row. Adding 1 to that gives you 0, and llDeleteSubString(str, 0, 0) deletes the first character. Removing the +1 makes it llDeleteSubString(str, 0, -1), which deletes the whole string.
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-25-2006 18:45
DOH! now I feel silly. You are right on! I only need to llSay(0, message); to get what I want. I had been sending email form one prim to another and I used the code to strip the header. I was not thinking when I combined the functions into one script that I woudl not need to remove the header...

Thank you Thank you! :)

From: Masakazu Kojima
The "headers" which that snippet refers to are the four lines that llEmail() inserts into the body of outgoing emails containing the object name, region, and position. It sounds like are getting those confused with normal email headers. If you are sending an email to your object from outside of SL, it will not have those headers inserted into the body of the email, so you don't need to remove them.

What's happening is: llSubStringIndex(message, "\n\n";); is returning -1 since there aren't two newlines in a row. Adding 1 to that gives you 0, and llDeleteSubString(str, 0, 0) deletes the first character. Removing the +1 makes it llDeleteSubString(str, 0, -1), which deletes the whole string.