ASCII Character Validation
Posted: Thu Jun 18, 2015 8:32 pm
Hello,
I currently have a program that emails our clients with a random word (reference). The reference is unique and can contain letters, numbers and the following symbols: * $ ! & % ? ^
The letters, numbers and symbols are held in an array, and when the reference needs to be created, it uses the random() method to pick a position from the array and then adds the character at that position to the reference.
Once this has been done, the reference is then emailed but I am getting the error message that the reference contians an non-ASCII character.
I have put in validation, such as:
But this does not seem to be working. Just to confirm that I would check once the email has been sent as thats when I would get something in smtp_connection.result? If not, could someone suggest where I would place it?
Furthermore, is it not possible to have the validation in the method where the reference is being created? For example, when the reference is created, validate it there and then and if it fails, create another one and keep doing this check until it is valid?
Thanks,
Omash
I currently have a program that emails our clients with a random word (reference). The reference is unique and can contain letters, numbers and the following symbols: * $ ! & % ? ^
The letters, numbers and symbols are held in an array, and when the reference needs to be created, it uses the random() method to pick a position from the array and then adds the character at that position to the reference.
Once this has been done, the reference is then emailed but I am getting the error message that the reference contians an non-ASCII character.
I have put in validation, such as:
Code: Select all
vars
smtp_connection : CnSmtpConnection;
begin
smtp_connection.name := str_mailServer;
smtp_connection.sendFrom := str_mailFrom;
smtp_connection.sendTo := str_mailTo;
smtp_connection.subject := str_mailSubject;
smtp_connection.contentType := "html";
smtp_connection.message:= "<html>";
smtp_connection.message:= smtp_connection.essage & str_uniqueReference;
smtp_connection.message:= smtp_connection.essage & str_additionalMessage;
smtp_connection.message:= smtp_connection.essage & "</html>";
smtp_connection.send;
if smtp_connection.result.bitAnd(CnSmtpConnection.Err_Non_ASCII_Character) <> null then
// Create a New Reference and Recall this Method using the New Reference as str_uniqueReference
endif;
if global.isValidObject(smtp_connection) then
app.doWindowEvents(10);
endif;
Furthermore, is it not possible to have the validation in the method where the reference is being created? For example, when the reference is created, validate it there and then and if it fails, create another one and keep doing this check until it is valid?
Thanks,
Omash