// This script demonstrates sending an EMail // values given for IP Addresses etc may not work because // you need your valid values // the EMail is defined by variables and send once // after sending the script stops. // no other communication is used // script is for Protocol Developer from V2.0 only // necessary script revision is 22 ScriptName "example sending EMail" ScriptAuthor "JO/dA" ScriptVersion "V1.0" // some variable declarations // ------------------------- var vb_channel: Byte; var va_Body: Buffer[100]; var va_from: Buffer[50]; var va_to: Buffer[50]; var va_subject: Buffer[50]; var va_server: Buffer[50]; var va_bcc: Buffer[50]; var va_cc: Buffer[50]; var va_DNS_IP_Address: Buffer[20]; var vl_DNS_IP_Address: long; // All strings must be terminated by #0 // define the body for the message MoveConst (va_Body[0], "This is a testmail!"#13#10#0 ); // define the name the mail receiver sees in his FROM item MoveConst (va_from[0], "UNIGATE@deutschmann.de"#0 ); // define the receivers Mail address // make sure to set your valid name here MoveConst (va_to[0], "user@mailserver.com"#0 ); // you have to define the email server // it is possible to give the IP Address as a null-terminated-string or // as a null terminated server name // MoveConst (va_Server[0], "mail.mailserver.com"#0 ); MoveConst (va_Server[0], "1.2.3.4"#0 ); // define the subject of the mail MoveConst (va_subject[0],"testing mail functionality"#0 ); // it is possible to define some additional receivers // also zero-terminated-strings, items separated by semicolons MoveConst (va_cc[0], #0 ); // "user1@mailserver.com;user2@mailserver.com"#0 ) MoveConst (va_bcc[0], #0 ); // the Send EMail function resolves names with a Domain Name Server. // You need to define the IP-Address of a DNS MoveConst( va_DNS_IP_Address[0], "15.16.17.18"#0 ); Convert( va_DNS_IP_Address[0], ASCII_IP, vl_DNS_IP_Address, long); SetByVar( DNS_IP_Address , vl_DNS_IP_Address ) ; // apply the mail servers address SetByVar ( SMTP_Server , va_server[0] ) ; // You need one ethernet communication channel for // sending an EMail. // We use channel 0 for demonstration of EMail MoveConst (vb_channel, 0 ); InitFastEthernet (vb_channel, EMail) ; // initalising Ethernet Hardware BusStart; // wait for hardware to be initialized Wait ( Bus_Active ) ; // Select channel 0 for EMail Set ( CommunicationChannel , 0) ; // Wahl des Kanals // sending the mail SendEMail( vb_channel, va_from[0], va_to[0], va_Body[0], va_subject[0], va_cc[0], va_bcc[0]) ; stop;