Difference between revisions of "Email"

From Second Life Wiki
Jump to: navigation, search
(an additional solution to solve objects relying upon email communications not working after sim updates)
m
Line 21: Line 21:
 
Emails sent may eventually be received after a restart/region-cross. Hence, don't rely on this event for reliable inter-region messaging.  
 
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=<lsl>default
+
|examples=
 +
<lsl>
 +
default
 
{
 
{
 
     state_entry()
 
     state_entry()
Line 27: Line 29:
 
         llSetTimerEvent(5.0);
 
         llSetTimerEvent(5.0);
 
     }
 
     }
+
 
 
     timer()
 
     timer()
 
     {
 
     {
 +
    //  get next email, don't filter by sender or subject
 
         llGetNextEmail("", "");
 
         llGetNextEmail("", "");
 
     }
 
     }
+
 
 
     email( string time, string address, string subject, string message, integer num_left )
 
     email( string time, string address, string subject, string message, integer num_left )
 
     {
 
     {
 +
    //  if we received an email from an object within Second Life
 
         if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
 
         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);
 
             message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
        }
+
//      }
       
+
 
         llSay(0, message);
+
    //  PUBLIC_CHANNEL has the integer value 0
 +
         llSay(PUBLIC_CHANNEL, message);
  
 +
    //  if there's another email in the queue waiting
 +
    //  get next email, don't filter by sender or subject
 
         if(num_left)
 
         if(num_left)
 
             llGetNextEmail("", "");
 
             llGetNextEmail("", "");
 
     }
 
     }
}</lsl>
+
}
 +
</lsl>
 
|helpers
 
|helpers
 
|also_header
 
|also_header

Revision as of 14:34, 28 October 2012

Description

Event: email( string time, string address, string subject, string message, integer num_left ){ ; }

Triggered as a result of calling llGetNextEmail where there is a matching email in the email queue.

• string time In the (string)llGetUnixTime format
• string address
• string subject
• string message
• integer num_left The number of emails remaining in the email queue.[1]

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

Specification

The email event is triggered as a result of calling llGetNextEmail when there is an email that matches llGetNextEmail's optional filters. The first email that matches the filters is removed from the email queue and it's data is used as the parameters for this event. If no email matches the filters but the queue is not empty this event is not triggered. Besides the effects of filtering, the email queue is FIFO.

Caveats

  • The email queue is limited to 100 emails, any email after that is bounced.
  • The message field may have a maximum of 1000 single-byte characters. This count includes the header information (address, subject, etc).
  • Emails sent from within SL will have 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).

Copiable objects may be drag-copied inworld to create a new duplicate in its place and restarted. The new copy will (usually) work in its place, and the old unworking object may be deleted. (ed. by Nyoko Salome 120816)

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()
   {
   //  get next email, don't filter by sender or subject
       llGetNextEmail("", "");
   }
   email( string time, string address, string subject, string message, integer num_left )
   {
   //  if we received an email from an object within Second Life
       if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")

// {

           message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);

// }

   //  PUBLIC_CHANNEL has the integer value 0
       llSay(PUBLIC_CHANNEL, message);
   //  if there's another email in the queue waiting
   //  get next email, don't filter by sender or subject
       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

Issues

All Issues

~ Search JIRA for related Issues
   Region incoming email queue for objects becomes suspended

Footnotes

  1. ^ The email being processed is not counted as it has already been popped from the queue.
  2. ^ 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 );