Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can I generate dynamic attachment sizes for SMTP load testing ?

How can I generate dynamic attachment sizes for SMTP load testing ?

This can be done by using the following BDL code. Copy and paste this code into a Silk Performer script.

This code will make a connection to a SMTP server, send messages of varying attachment sizes, then close the connection.

benchmark SmtpTest

use "WebAPI.bdh"

const
sentFrom := "user.name@myCompany.com"; //user sending email
sentTo := "user.name@myCompany.com"; // user receiving email
sHost := "smtp.Mycompany.com"; // smtp server name.
nPort := 25; //smtp port

dcluser
user
VUser
transactions
TInit : Begin;
TMain : 1;
TEnd : End;

var
// Declare variables
i : Number;
nDate, nTime : Number;
hSmtp0 : Number;

sPort : String(100);
RunTime : String;
emailName : String;
emailTime : String;
sEmailLn : String;
emailText : String(400000);
emailTemp : String(400000);

dclrand
// random number between 1 and 200 that is passed to the function func1
rnEmailLn : RndUniN(1..200);

dclfunc
// create message bodies of random length
// function accepts a number p1 as input
// returns a string that has p1 number of lines

function func1(p1: number): string(400000)
var
j: number;

begin
func1 := "";

for j := 1 to p1 do
func1 := func1 + "Line " + string(j) + " of email text string.\r\n";
func1 := func1 + "Line " + string(j);
end;
end Func1;

dcltrans

transaction TInit
var

begin
WebSmtpConnect(hSmtp0, sHost, nPort);
WebSmtpHelloEx(hSmtp0, sPort); // Host name of the SMTP sender, for example,
end TInit;

transaction TMain
var
begin

nDate := GetCurrentDate();
nTime := GetCurrentTime();
FormatDateTime(nDate, nTime, "%x %X", RunTime);

emailTime := Runtime;
emailName := "Test Message " + emailTime;
emailText := "This is a test message created at " + emailTime + "\r\n";
emailtemp := func1(rnEmailLn);
emailText := emailText + emailTemp;

WebSmtpMail(hSmtp0, sentFrom);
WebSmtpRecipient(hSmtp0, sentTo);

WebSmtpDataEx(hSmtp0,sentTo, sentFrom, emailName, emailText);

end TMain;

transaction TEnd
var
begin
WebSmtpQuit(hSmtp0);
WebSmtpShutdown(hSmtp0);
end TEnd;

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:02
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.