Difference between revisions of "Email"

From Second Life Wiki
Jump to: navigation, search
(i'm still working here)
Line 4: Line 4:
 
|p1_type=string|p1_name=time|p1_desc=In the <code>(string)[[llGetUnixTime]]</code> format
 
|p1_type=string|p1_name=time|p1_desc=In the <code>(string)[[llGetUnixTime]]</code> format
 
|p2_type=string|p2_name=address|p2_desc
 
|p2_type=string|p2_name=address|p2_desc
|p3_type=string|p3_name=subject|p3_desc|
+
|p3_type=string|p3_name=subject|p3_desc
p4_type=string|p4_name=message|p4_desc
+
|p4_type=string|p4_name=message|p4_desc
 
|p5_type=integer|p5_name=num_left|p5_desc=The number of emails left in the email queue
 
|p5_type=integer|p5_name=num_left|p5_desc=The number of emails left in the email queue
|event_desc=Triggered when task receives email
+
|event_desc=Triggered as a result of calling [[llGetNextEmail]] when there is an email that matches the optional filters used during the [[llGetNextEmail]] call. The email is removed from the email queue.
 +
|event_footnote=The email queue is associated with the prim and any script in the prim has access to it. <br/> The prim's email address is it's key with "@lsl.secondlife.com" appended, <code>[[llGetKey]]() + "@lsl.secondlife.com"</code>{{Footnote|Preview grid email address are constructed differently: <code>[[llGetKey]]() + "@lsl." + grid + ".lindenlab.com"</code>; for the main beta grid set grid to {{String|aditi}}.|Beta grid email address are constructed differently: llGetKey() + {{String|@lsl.}} + grid + {{String|.lindenlab.com}}; for the main beta grid set grid to {{String|aditi}}.}}.
 
|constants
 
|constants
 
|spec
 
|spec
 
|caveats=
 
|caveats=
*The email queue is limited to 100 emails, any email after that is bounced.
+
* The email queue is limited to 100 emails, any email after that is bounced.
* Due to bug {{Jira|SVC-23}} (present since 2005), objects may stop receiving emails completely until either the region is restarted or the object crosses a region boundary (resetting the script doesn't help).  Emails sent may eventually be received after a restart/region-cross. Hence, don't rely on this event for reliable inter-region messaging.
+
* The message field may have a maximum of 1000 characters. This count includes the header information (the from address, and the subject).
*The message field may have a maximum of 1000 characters. This count includes header information, which is pre-pended, and over which you have no control.
+
* [[llEmail|Emails sent from within SL]] will have the their message body prefixed with a header detailing the originating prim. See [[llEmail]] for more details.
 +
* Due to bug {{Jira|SVC-23}} (present since 2005), objects may stop receiving emails completely until either the region is restarted or the object crosses a region boundary (resetting the script doesn't help).  Emails sent may eventually be received after a restart/region-cross. Hence, don't rely on this event for reliable inter-region messaging.  
 
|constants
 
|constants
|examples=
+
|examples=<lsl>default
 
+
The message field for email sent by llEmail will look like this:
+
 
+
Object-Name: Name of the object that sent the email<br />
+
Region: The name of the Region (PLUS, in round brackets, the region_corner _coordinates)<br />
+
Local-Position: the local position of the object sending the email<br />
+
 
+
message_text
+
 
+
(Note: to be clear, the labels Object-Name:, etc, are actually returned to you as well.)
+
 
+
 
+
To get just the pure message text, minus the headers, do this:
+
 
+
<lsl>
+
message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
+
</lsl>
+
 
+
 
+
To get just 1 of the header items, do this:
+
 
+
<lsl>
+
list TempList = llParseStringKeepNulls(message, ["\n"], []);
+
string objname = llList2String(TempList,0);
+
string tmpregion = llList2String(TempList,1);
+
string localpos = llList2String(TempList,2);
+
</lsl>
+
 
+
To get a pure region name, do this:
+
 
+
<lsl>
+
string right (string src, string divider) {
+
 
+
                integer iStart = llSubStringIndex( src, divider ) + 1;
+
                string result = llGetSubString( src, iStart, llStringLength(src) - 1 ) ;
+
      return result;
+
}
+
 
+
string left (string src, string divider) {
+
                integer iStart = llSubStringIndex( src, divider ) + 1;
+
                string result = llGetSubString( src, 0, iStart -1) ;
+
      return result;
+
}
+
 
+
list TempList = llParseStringKeepNulls(message, ["\n"], []);
+
string tmpregion = right(llList2String(TempList,1),": ");
+
tmpregion = llStringTrim(left(tmpregion," ("),STRING_TRIM);
+
</lsl>
+
 
+
 
+
 
+
This application uses email to have objects check with a central server to see if the owner has the latest version. In the objects:
+
<lsl>
+
string version = "1"; //
+
string type = "lolcube";
+
default
+
{
+
    on_rez(integer start_param)
+
    {
+
        llEmail("5a634b27-f032-283f-2df2-55ead7724b23@lsl.secondlife.com",
+
            version,
+
            (string)llGetOwner()+","+type);
+
    }
+
}</lsl>
+
The server:
+
<lsl>
+
default
+
 
{
 
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         llSetTimerEvent(15);
+
         llSetTimerEvent(5.0);
 
     }
 
     }
   
+
 
     timer()
 
     timer()
 
     {
 
     {
         llGetNextEmail("","");
+
         llGetNextEmail("", "");
 
     }
 
     }
   
+
     email( string time, string address, string version, string message, integer num_left )
+
     email( string time, string address, string subject, string message, integer num_left )
     {  
+
     {
         if ((integer)version < 2)
+
         if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
         {
+
         {//Message was sent from within SL. For this example we will just strip the header.
             list info = llCSV2List(llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1));
+
             message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
            llGiveInventory(llList2Key(info,0),llList2String(info,1));
+
 
         }
 
         }
 
          
 
          
         integer i;
+
         llSay(0, message);
         for (i = 0; i < num_left; i++)
+
 
        {
+
         if(num_left)
             llGetNextEmail("","");
+
             llGetNextEmail("", "");
        }
+
 
     }
 
     }
}
+
}</lsl>
</lsl>
+
 
|helpers
 
|helpers
 
|also_header
 
|also_header
Line 117: Line 49:
 
|also_articles
 
|also_articles
 
|also_footer
 
|also_footer
|notes
+
|notes=
 +
For tips on how to process emails sent from within SL, see the entry on [[llEmail#Prim2Prim_Email|llEmail]].
 
|mode
 
|mode
 
|deprecated
 
|deprecated

Revision as of 12:42, 11 October 2008

Description

Event: email( string <span title="In the (string)llGetUnixTime format" style="border-bottom:1px dotted; cursor:help;">time, string address, string subject, string message, integer num_left ){ ; }</span>

Triggered as a result of calling llGetNextEmail when there is an email that matches the optional filters used during the llGetNextEmail call. The email is removed from the email queue.

• string time In the (string)llGetUnixTime format
• string address
• string subject
• string message
• integer num_left The number of emails left in the email queue

The email queue is associated with the prim and any script in the prim has access to it.
The prim's email address is it's key with "@lsl.secondlife.com" appended, llGetKey() + "@lsl.secondlife.com"[1].

Caveats

  • The email queue is limited to 100 emails, any email after that is bounced.
  • The message field may have a maximum of 1000 characters. This count includes the header information (the from address, and the subject).
  • Emails sent from within SL will have the their message body prefixed with a header detailing the originating prim. See llEmail for more details.
  • Due to bug SVC-23 (present since 2005), objects may stop receiving emails completely until either the region is restarted or the object crosses a region boundary (resetting the script doesn't help). Emails sent may eventually be received after a restart/region-cross. Hence, don't rely on this event for reliable inter-region messaging.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>default {

   state_entry()
   {
       llSetTimerEvent(5.0);
   }

   timer()
   {
       llGetNextEmail("", "");
   }

   email( string time, string address, string subject, string message, integer num_left )
   {
       if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
       {//Message was sent from within SL. For this example we will just strip the header.
           message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
       }
       
       llSay(0, message);
       if(num_left)
           llGetNextEmail("", "");
   }

}</lsl>

Notes

For tips on how to process emails sent from within SL, see the entry on llEmail.

See Also

Functions

•  llEmail
•  llGetNextEmail

Deep Notes

Footnotes

  1. ^ Preview grid email address are constructed differently: llGetKey() + "@lsl." + grid + ".lindenlab.com"; for the main beta grid set grid to "aditi".

Signature

event void email( string time, string address, string subject, string message, integer num_left );