Thank you so much Marsha for the response.
I mean it just worked onetime randomly in the middle. I am not sure about the reason. Well, i would try as you said. Could you tell me what i need to add in the below code which is in javascript.
// MS Outlook constants
var
olMailItem = 0;
olByValue = 1;
olContactItem = 2;
var MsOutlook, NS, ContactFldr;
function Outlook_Test()
{
if (!InitializeOutlook())
Log.Warning("Unable to initialize MS Outlook or its folders.", "", pmHigher);
else
{
SendReport("source email", "destination email", "company",
"D:\\Data\\TestDocument.txt");
}
}
// Initializes MS Outlook
function InitializeOutlook()
{
try
{
try
{
MsOutlook = Sys.OleObject("Outlook.Application");
}
catch(exception)
{
MsOutlook = Sys.OleObject("Outlook.Application.16");
}
// NS = MsOutlook.GetNamespace("MAPI");
// ContactFldr=NS.AddressLists;
//ContactFldr = NS.Folders("Personal Folders").Folders("Contacts");
}
catch(exception)
{
Log.Warning(exception+"Unable to initialize MS Outlook.", "", pmHigher);
return false;
}
return true;
}
// Sends a report to the user
function SendReport(Name1, Name2, Company, FileNameToAttach)
{
var ObjItem, MI, i, CRLF;
CRLF = "\n";
// Creates a new message
MI = MsOutlook.CreateItem(olMailItem);
// Sets the message subject
MI.Subject = "Test Results";
MI.Body= "Sample test";
// Specifies the destination address
MI.To = "Destination address";
// 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();
}