Use LoadRunner to test the 139 email script, and use javavuser to write a Java Script to call the mail package to send emails, including attachments:
Import java. util. date;
Import java. util. properties;
Import javax. Mail .*;
Import javax. Mail. Internet .*;
Import com. Sun. Mail. SMTP .*;
Public class actions
{
Public int Init (){
Return 0;
} // End of init
Public int action (){
Boolean SSL = false;
Properties props = system. getproperties ();
// Set the SMTP host address
Props. Put ("mail. SMTP. Host", "123.125.50.htm ");
// Set the SMTP port number. 465 is SSL, and 25 is non-SSL port.
Props. Put ("mail. SMTP. Port", SSL? "465": "25 ");
// Set the SMTP User Name
Props. Put ("mail. SMTP. User", "xxxx@139.com ");
Session session = session. getinstance (props, null );
String Mailer = "send from VU Java SMTP ";
// Set the recipient
String sendto = "xxxx@139.com ";
// Set CC recipients
String sendcc = "";
// Set the sender
String sendfrom = "xxxx@139.com ";
Try {
Smtptransport t = (smtptransport) Session. gettransport (SSL? "Smtps": "SMTP ");
// Connect to the SMTP host
T. Connect ("123.125.50.large", "xxxx@139.com", "XXX ");
Mimemessage MSG = new mimemessage (session );
Attachment attachment = new attachment ();
Attachment. setfile (f );
// Set various email fields
String subject = "SMTP test ";
String personalname = "LR performance test user ";
String body = "There are a lot of content here \ r \ n there are a lot of content here ";
String charset = "UTF-8 ";
String name = "sendjob. Java ";
String filepath = "C:/users/Administrator/desktop/mailsender ";
Internetaddress [] to = new internetaddress [1];
Internetaddress from = new internetaddress (sendfrom, personalname, charset );
To [0] = new internetaddress (sendto, personalname, charset );
Attachment. setname (name );
Attachments. Add (Attachment );
MSG. setfrom (from );
MSG. setrecipients (message. recipienttype. To, );
MSG. setsubject (subject, charset );
MSG. settext (body, charset );
MSG. setsentdate (new date ());
// Send an email
T. sendmessage (MSG, MSG. getallrecipients ());
T. Close ();
}
Catch (exception e ){
E. printstacktrace ();
}
Finally {
}
Return 0;
} // End of action
/**
* Add attachment
*
* @ Param name
* @ Param path
* @ Throws filenotfoundexception
*/
Public void addattachment (string name, string filepath)
Throws filenotfoundexception {
File F = new file (filepath );
If (! F. exists ()){
Throw new filenotfoundexception ("file [" + filepath + "] Not Found ");
}
}
/**
* Add attachment
*
* @ Param filepath
* @ Throws filenotfoundexception
*/
Public int end (){
Return 0;
} // End of end
}