how to config mailclient in test complete or how to send test result to mail via test complete
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to config mailclient in test complete or how to send test result to mail via test complete
how to config mailclient in test complete or how to send test result to mail via test complete
Hi,
I'm using test complete and I want to send my log result for every single case after the test run completed even if it passed or failed , How can I config to make that happen?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi rraghavi,
need step-by-step guidance to perform the operation.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first step is to read what I've provided; second step, is to try and understand it; third step, is to try it; fourth step, any issues then let us know.
I won't provide step by step guidance, as everything is mentioned in the TestComplete documentation.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@sanjayram If you have questions after you've tried it, post your code and the results here and then we can try to help you.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In this script MAPI has failed
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
//This example demonstrates how you can work with Microsoft Outlook from
scripts. It will send messages long with attached script code to John Smith,
John Smith Corp., at JohnSmith@JohnSmithCorp.com.
Run the Outlook_Test procedure.
Requirements:
Microsoft Outlook must be installed on your computer.
NOTE: This example adds a new contact (John Smith, John Smith Corp.)
to your address book. Don't forget to remove it later. */
// MS Outlook constants
var
olMailItem = 0;
olByValue = 1;
olContactItem = 2;
function Outlook_Test()
{
var outlook = CreateOutlook()
if (GetContactByName(outlook, "sanjayram", "raja", "optisolbusinesssolution") == null)
AddContact(outlook, "sanjayram", "xxxx", "xxxxx", "sanjayram.r@xxxxx.com");
SendReport(outlook, "sanjayram", "xxxx", "xxxxxxx",
Project.Path + "\\" + "Script\\Outlook_JS.sj");
}
// Initializes MS Outlook
//function CreateOutlook()
//{
//try
//{
//return Sys.ActiveXObject("Outlook.Application");
//}
//catch (exception)
//{
//return Sys.OleObject("Outlook.Application.12");
//}
//}
function CreateOutlook() {
try {
return new ActiveXObject("Outlook.Application");
} catch (exception) {
try {
return new ActiveXObject("Outlook.Application.12");
} catch (exception) {
// Handle the exception here if needed
return null;
}
}
}
// Returns the ContactItem object by user name
function GetContactByName(outlook, firstName, lastName, company)
{
var ns = outlook.GetNamespace("MAPI");
for (var j = 1; j <= ns.AddressLists.Count; j++)
{
var list = ns.AddressLists.Item(j).AddressEntries
for (var i = 1; i <= list.Count; i++)
{
var contact = list.Item(i).GetContact();
if ( contact != null &&
contact.FirstName == firstName &&
contact.LastName == lastName &&
contact.CompanyName == company )
return contact;
}
}
return null;
}
// Adds a new contact
function AddContact(outlook, firstName, lastName, company, email)
{
var contact = outlook.CreateItem(olContactItem);
contact.FirstName = firstName;
contact.LastName = lastName;
contact.CompanyName = company;
contact.Email1Address = email;
contact.Save();
}
// Sends a report to the user
function SendReport(outlook, firstName, lastName, company, fileNameToAttach)
{
var contact = GetContactByName(outlook, firstName, lastName, company);
if (contact == null)
{
Log.Error("User " + firstName + " " + lastName + " was not found in the address book.");
return;
}
// Creates a new message
var mi = outlook.CreateItem(olMailItem);
// Sets the message subject
mi.Subject = "Test Results";
// Sets the message text
mi.Body = "Hello, " + contact.FirstName + "\n" +
"Today my regression test failed.\n" +
"The script is attached.\n\n" +
"Good Luck,\n" +
"Your tester";
// Specifies the destination address
mi.To = contact.Email1Address;
// Attaches the script code
mi.Attachments.Add(fileNameToAttach, olByValue, mi.Body.length, "Script");
mi.Display(); // This line displays the new mail on screen.
// To send the mail, use the Send method
// mi.Send();
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The coding you have provided, is that something you have written or copied it from somewhere?
Have you read the information that I provided in the links? and seen the code example?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@sanjayram I see that you have used an example and put your own information in it. However "MAPI has failed" is not enough information for us. Please show the line of code where the script failed and give us the error message.
