mIRC Home    About    Download    Register    News    Help

Print Thread
#141744 12/02/06 11:01 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I'm new to dialog boxes, but I've got this one set up how I want it. I just need to figure out how to script an event for when the text in the edit boxes is finished. I'll handle what to do with the data, it's just that I can't seem to get it to work where the variables equal anything. Here's the script:
Code:
dialog test {
  title "Blake's Email Program"
  size -1 -1 250 200
  option dbu

  text "To:", 1, 5 10 10 10 
  edit "", 2, 5 18 240 10, %ToAddress
  text "Subject:", 3, 5 33 240 10
  edit "", 4, 5 41 240 10, %Subject
  icon 8, 5 55 240 50, Image018.jpg
  text "Body:", 5, 5 105 20 50
  button "Send", 6, 170 103 20 10, cancel
  edit "", 7, 5 115 240 80,multi,return,autovs %Body
}

I tried to use an on SCLICK event, but the variables didn't equal anything when I echoed them. Thanks for any help.

#141745 12/02/06 11:05 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Quote:
Variables
If you specify a %variable name in a dialog item definition, the %variable will be set with the contents of that item when the dialog is closed .



/help /dialog

#141746 12/02/06 11:30 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I read that in the help, and the variables are getting set when it closes, but this doesn't work, and I'm not sure why
Code:
on *:dialog:test:close: {
  echo -a %toaddress 
}

#141747 12/02/06 11:43 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Why does this work
Code:
on *:dialog:test:sclick:6:{
  echo -a $did(test,2).text 
  echo -a $did(test,4).text
  echo -a $did(test,6).text
}

And this doesn't
Code:
on *:dialog:test:close:6:{
  echo -a $did(test,2).text 
  echo -a $did(test,4).text
  echo -a $did(test,6).text
}

#141748 13/02/06 12:13 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
on *:DIALOG:dialogname:close:0:{

-genius_at_work

#141749 13/02/06 01:04 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
As genius_at_work shows, the ID for the close is 0
From the help file
Quote:
close when a dialog is closed. ID is zero.


Note: that you can use a wildcard for the ID in some situations. (like this one)

#141750 13/02/06 02:59 AM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Thanks. I figured that part out. Now I have another problem involving sockets. This is very similar to another problem I posted about recently. I'm not getting any errors, but the text file isn't getting written and I'm not getting any emails when I send to myself. Any ideas?
[code]
on *:sockopen:sendmail:{
var %temptext
sockread %temptext
}
on *:sockread:sendmail:{
while ($sockbr) {
sockread %temptext
write mailtemp.txt %temptext
if ($gettok(%temptext,1,32) == 220) { sockwrite -n $sockname helo $host }
if ($gettok(%temptext,1,32) == 250) { sockwrite -n $sockname MAIL From:MyEmailAddress }
if ($gettok(%temptext,1,32) == Sender) && ($gettok(%temptext,4,32) == Ok) { sockwrite -n $sockname RCPT To: $+ %toaddress }
if ($gettok(%temptext,1,32) == Recipient) && ($gettok(%temptext,4,32) == Ok) { sockwrite -n $sockname data }
sockwrite -n $sockname Subject: %subject
sockwrite -n $sockname $crlf
sockwrite -n $sockname %body
sockwrite -n $sockname .
sockwrite -n $sockname quit
sockclose sendmail
}
}

Last edited by bwr30060; 13/02/06 03:12 AM.
#141751 13/02/06 03:21 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
If the text file isn't being written, then the problem is with your while loop. The $sockbr holds the number of bytes that were read from the last /sockread command. Since you use the /sockread command AFTER the $sockbr while loop, $sockbr is 0, and the while loop never executes.

Try using this for that part of the code:

Code:
on *:sockread:sendmail:{ 
  [color:red]sockread %temptext[/color]
  while ($sockbr) { 
    sockread %temptext


-genius_at_work

#141752 13/02/06 03:31 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You shouldn't use the sockread command in an on sockopen event. In this case you don't need an on sockopen event at all if the server if the first thing to send data.

#141753 13/02/06 03:51 AM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I still can't get this working. I realized that I don't need an ON SOCKOPEN event, so I took it out. I added echoes for testing, and it echoes one line, then tells me "* /echo: insufficient parameters (line 26, mail.mrc)". I'm assuming that this is because my variable has no value. It's still not sending emails or writing anything to the text file.
Code:
on *:sockread:sendmail:{
  sockread %temptext
  echo -a %temptext
  while (%temptext) {
    sockread %temptext  
    echo -a %temptext
    write mailtemp.txt %temptext
    if ($gettok(%temptext,1,32) == 220) { sockwrite -n $sockname helo $host }
    if ($gettok(%temptext,1,32) == 250) && ($left(gettok(%temptext,2,32),3) == ibm) { sockwrite -n $sockname MAIL From:MyEmailAddress }
    if ($gettok(%temptext,1,32) == Sender) && ($gettok(%temptext,4,32) == Ok) { sockwrite -n $sockname RCPT To: $+ %toaddress }
    if ($gettok(%temptext,1,32) == Recipient) && ($gettok(%temptext,4,32) == Ok) { sockwrite -n $sockname data }
    if ($gettok(%temptext,2,32) == Mail) && ($gettok(%temptext,3,32) == queued) { halt }
  }    
  else {
    sockwrite -n $sockname Subject: %subject
    sockwrite -n $sockname $crlf
    sockwrite -n $sockname %body
    sockwrite -n $sockname .
    sockwrite -n $sockname quit
    sockclose sendmail
  }
}

#141754 13/02/06 05:12 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Try this code:

Code:
alias mail {
  [color:red];------ SET THESE VALUES THEN CALL /mail -----
  set %fromaddress from@email.com
  set %toaddress to@email.com
  set %subject This is the subject
  set %body This is the body
  var %host
  ;------[/color]
  ;
  set %logfile $+(maillog.,$asctime(dd.mm.yyyy),.txt)
  set %sendstate 1
  if ($sock(sendmail)) sockclose sendmail
  write %logfile # Connect Attempt to 
  sockopen sendmail shawmail.ok.shawcable.net 25
}
;
on *:sockread:sendmail:{ 
  var %temptext
  sockread %temptext
  tokenize 32 %temptext

  write %logfile $asctime(HH:nn:ss) -> $1- 
  if ((%sendstate == 1) && ($1 == 220)) {
    mailsockwrite HELO localhost
    echo 3 -a HELO
    inc %sendstate
  } 
  elseif ((%sendstate == 2) && ($1 == 250)) { 
    mailsockwrite MAIL From: $+ %fromaddress
    echo 3 -a MAIL
    inc %sendstate
  }
  elseif ((%sendstate == 3) && ($1 == 250)) { 
    mailsockwrite RCPT To: $+ %toaddress 
    echo 3 -a RCPT
    inc %sendstate
  } 
  elseif ((%sendstate == 4) && ($1 == 250)) { 
    mailsockwrite DATA 
    echo 3 -a DATA
    inc %sendstate
  }
  elseif ((%sendstate == 5) && ($1 == 354)) {
    mailsockwrite Subject: %subject 
    mailsockwrite $crlf 
    mailsockwrite %body 
    mailsockwrite . 
    echo 3 -a SEND
    inc %sendstate
  }
  elseif ((%sendstate == 6) && ($1 == 250)) {
    mailsockwrite QUIT
    echo 3 -a QUIT
    inc %sendstate
  }
  elseif ((%sendstate == 7) && ($1 == 221)) {
    sockclose $sockname
    echo 3 -a DONE
  }
  elseif ((%sendstate < 0) && ($1 == 221)) {
    sockclose $sockname
    echo 4 -a DONE
  }
  else {
    mailsockwrite QUIT
    echo 4 -a ERROR: $1-
    set %sendstate -1
  }
} 
;
alias mailsockwrite {
  sockwrite -n $sockname $1-
  write %logfile $asctime(HH:nn:ss) <- $1-
}


Note that I knew nothing about SMTP before I read this site: http://www.opus1.com/www/presentations/emailproto/sld006.htm

The above code should cancel the send if there is an unexpected message from the server (ie. an error). You need to set the variables at the beginning of the /mail alias using your own code/dialogs/etc.. Everything after the ;----- in the /mail alias should remain the same. Once those variables are set, you call the /mail alias to send the email.

-genius_at_work


Link Copied to Clipboard