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

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
Answers (1)
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
// 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.
// Sample code of the usage of the variable with the information to be sent.
smtp_send_mail( ''SendMail'',
''Subject=Sample information only'',
MAILDATA, maintext1, LAST);

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

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

Scroll to Top