backIndex

Xelagot action script

Events: EmailSend, EmailSuccess, EmailFailed

Refer to Events for general information.

EmailSend event is triggered when the bot starts sending an e-mail, after the statement EmailSend. E-mails to be sent are queued, and the bot sends them one at a time: each sending triggers this event. This will be followed by one of the following two events:

EmailSuccess or EmailFailed are triggered after the bot sends an e-mail with the statement EmailSend, after the event EmailSend has been triggered. See also Xelagot Topics: Sending Email.

Installers:

OnEmailSendEvent <eventlabel>
Event type: 10000

OnEmailSuccessEvent <eventlabel>
Event type: 10001

OnEmailFailedEvent <eventlabel>
Event type: 10002

Specific statements (must be inside the event handler):

GetEventType %a stores the event type code in variable %a
GetEventResult %a stores the event result code in variable %a. 0 means success (always in EmailSend and EmailSuccess), -1 means failure (always in EmailFailed).
GetEventEmailCode $a stores the success or error code in variable $a. The code is "MailStart" in event EmailSend, "MailSent" in event EmailSuccess. The error codes in event EmailFailed are: "MailFailed" (generic), "MailAborted" (generic), "ConnectionRequired" (not connected to Internet), "ConnectionFailed" (can not connect to SMTP server), "InvalidHost" (host blank or invalid, can not connect to SMTP server), "DisconnectedByHost" (disconnected while sending mail), "AuthenticationFailed" (when login name is required and rejected), "InvalidHeader" (required headers invalid), "InvalidFromAddress" (your e-mail address is invalid or blank), "InvalidToAddress" (invalid or blank addressee), "RecipientNotFound" (adressee not found). Some of these codes will never occur because the validity of the addressee is not normally checked.
GetEventEmailID $a stores the ID code in variable $a. Compare it to the code you got in $ID with EmailSend $ID

An example... you need to edit the lines in red and change the data to your own.

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
var /s_a, $ID
  OnEmailSendEvent Email_Sending
  OnEmailSuccessEvent Email_Success
  OnEmailFailedEvent Email_Failed
  Gosub Email
Label LoopHere
  Goto LoopHere
Label Out
End

Sub Email
  # the Host SMTP Server goes here:
  EmailHost "smtp.whatever.com"
  # the SMTP Port is usually 25:
  EmailPort 25
  # if required, put your login name to log into the SMTP Server:
  EmailUserID  "MyLoginName"
  # your name, e.g.: "Charlie B. Brown"
  EmailFromName "My Usual Name"
  # your own email address, e.g. "charlie@hotmail.com"
  EmailFromAddress "MyEmail@whatever.com"
  # clear your email data (body, recipients etc):
  EmailClearParameters
  # send me an email:
  EmailToAddress "xelag@3dee.nl"
  # send yourself a copy, e.g.: "charlie@hotmail.com"
  EmailToCC "MyEmail@whatever.com"
  # the subject line:
  EmailSubject "testing xelagot action script mailer"
  # get the email body from the text field:
  SListSetText /s_a EmailBody
  # put it in the email:
  EmailBody /s_a
  # send it and recover the email's ID !
  EmailSend $ID
EndSub

Event Email_Sending
  GetEventEmailID $a
  IfStringExact $a <> $ID EndEvent
  SayConcat "Sending email " $ID "...."
EndEvent

Event Email_Success
  GetEventEmailID $a
  IfStringExact $a <> $ID EndEvent
  SayConcat "Email " $ID " sent successfully"
  EscapeTo Out
EndEvent

Event Email_Failed
  GetEventEmailID $a
  GetEventEmailCode $e
  IfStringExact $a <> $ID EndEvent
  SayConcat "Email " $ID " failed, reason " $e
  EscapeTo Out
EndEvent

Text EmailBody
Hi,
I love all bots
but especially my Xelagot :)
Bye
EndText



backIndex