Is it possible to parameterize and send dynamic values in the MessageText argument of smtp_send_mail function?
Question ID: 105968
0
0

I’m trying to pass dynamic values in the SMTP protocol script and when I use the smtp_send_mail function I’m unable to parameterize values that I’d like to submit in the body of the email. I’ve tried directly entering the parameters in or using lr_param_sprintf to format the message text and send as a parameter but it always gets treated literally and just sends "{""}.

Marked as spam
Posted by (Questions: 89, Answers: 0)
Asked on March 6, 2015 6:55 pm
107 views
Answers (1)
0
Private answer

@MHooper You can use parameterization only for the arguments within a function. You cannot parameterize text strings that are not function arguments.
You can use the lr_eval_string function to ''parameterize'' a function argument that you cannot parameterize by using standard parameterization. You can also use the lr_eval_string function to ''parameterize'' any string in a Vuser script

The following code is a sample code that indicates the steps to solve the issue. This code needs to be changed to make it work with the script. However the code works.
char maintext1[1024];
char maintext2[1024];
char *message1;
char *message2;
// Define the section that will be replaced
strcpy(maintext1,''MessageText='');
// Load the data from the parameter 1 into the message1 variable
message1 = lr_eval_string(''{Param1}'');
// Define the end-of-line, characters to be use in case of more lines in the message
strcpy(maintext2,'' '');
// Load the data from the parameter 2 into the message2 variable
message2 = lr_eval_string(''{Param2}'');
// Concatenates the message in the variable maintext1, data that is going to be included in the message.
strcat(maintext1,message1);
strcat(maintext1,maintext2);
strcat(maintext1,message2);
// Sample code of the usage of the variable with the information to be sent.
smtp_send_mail( ''SendMail'',
''To=some_email@server.com'',
''From=sample_code@sender.com'',
''Subject=Sample information only'',
''ContentType=text/plain;'',
''charset=''iso-8859-4'''',
MAILOPTIONS,
MAILDATA, maintext1, LAST);

Marked as spam
Posted by (Questions: 0, Answers: 90)
Answered on March 6, 2015 7:28 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top