muralidharan18
8 years agoOccasional Contributor
Automate Email Log
Hi, My requirement is to send my log through email automatically. How can i configure automatic email for log? Can any one help me? Thanks & Regards, Muralidharan
Hi,
I implemented this method, while executing I'm getting this error "Transport failed to connect to the Server".
How to rectify it?
Thanks & Regards,
Muralidharan
That sounds like an authentication error. Could you post the code that you implemented? It's possible that there's a parameter set wrong. Be sure you have your e-mail username and password correct and that your mail server information is correct as well.
Hi
This is my code.
function SendEmail(mFrom, mTo, mSubject, mBody, mAttach)
{
var i, schema, mConfig, mMessage;
try
{
schema = "http://schemas.microsoft.com/cdo/configuration/";
mConfig = Sys.OleObject("CDO.Configuration");
mConfig.Fields.Item(schema + "sendusing") = 2; // cdoSendUsingPort
mConfig.Fields.Item(schema + "smtpserver") = "smtp.gmail.com"; // SMTP server
mConfig.Fields.Item(schema + "smtpserverport") = 465; // Port number
// If you use Gmail --
// mConfig.Fields.Item(schema + "smtpserver") = "smtp.gmail.com";
// mConfig.Fields.Item(schema + "smtpserverport") = 465;
// If you use Outlook --
// mConfig.Fields.Item(schema + "smtpserver") = "smtp-mail.outlook.com";
// mConfig.Fields.Item(schema + "smtpserverport") = 25;
// If you use Office365 --
// mConfig.Fields.Item(schema + "smtpserver") = "smtp.office365.com";
// mConfig.Fields.Item(schema + "smtpserverport") = 587;
mConfig.Fields.Item(schema + "smtpauthenticate") = 1; // Authentication mechanism
mConfig.Fields.Item(schema + "smtpusessl") = true;
mConfig.Fields.Item(schema + "sendusername") = "My gmail ID"; // User name (if needed)
mConfig.Fields.Item(schema + "sendpassword") = "My password"; // User password (if needed)
mConfig.Fields.Update();
mMessage = Sys.OleObject("CDO.Message");
mMessage.Configuration = mConfig;
mMessage.From = mFrom;
mMessage.To = mTo;
mMessage.Subject = mSubject;
mMessage.HTMLBody = mBody;
aqString.ListSeparator = ",";
for(i = 0; i < aqString.GetListLength(mAttach); i++)
mMessage.AddAttachment(aqString.GetListItem(mAttach, i));
mMessage.Send();
}
catch (exception)
{
Log.Error("Email cannot be sent", exception.description);
return false;
}
Log.Message("Message to <" + mTo + "> was successfully sent");
return true;
}
function MainTest()
{
if (SendEmail("My Id", "Destination ID", "Subject", "Sample", "c:\\new\\Test.txt")){
Log.Checkpoint("Mail Sent Successfully");
}
else
{
Log.Error("Mail Not Sent");
}
}
Do I need to change anything else?
Thanks & Regards,
Muralidharan