Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Scheduler did'nt Catch the  Inner Catch while ErrorsScheduler did'nt Catch the Inner Catch while Errors
Previous
 
Next
New Post
2/13/2016 3:23 AM
 

I have the scheduler to read files(CSV) and send mail to the Emails, which is found from that document.

I am using the Scheduler with gmail's/our's smtp on local machine made no issues, while sending mail even with wrong "To:" mail id.
but in hosting when scheduler send mail to wrong mail id,  scheduler stops at smtp.Send(mail)  and Error caught. 

public override void DoWork()
{
      try
         {
              try
              {
                       this.Progressing();
                       string[] files = System.IO.Directory.GetFiles(System.Web.Hosting.HostingEnvironment.MapPath("/NewCSVContactFiles"));
                       foreach (string filePath in files)
                        {
                             DataTable dt = ConvertCSVFileToDataTable(filePath)
                             sendMails(dt);
                        }
                 }
                 
catch (Exception ex)
                 {
                        this.ScheduleHistoryItem.AddLogNote(" : " + ex.InnerException.ToString());
                        //Catch: HERE
                 }
                 this.ScheduleHistoryItem.Succeeded = true;
         }
        catch (Exception ex)

        {
                //--intimate the schedule mechanism to write log note in schedule history
                this.ScheduleHistoryItem.Succeeded = false;
                this.ScheduleHistoryItem.AddLogNote("FileProcessSchedule Start. Failed. " + ex.InnerException.ToString());
                this.Errored(ref ex);
        
}
}

public sendMails(Datatable dt)
{
      try
         {
                foreach (DataRow row in dt.Rows)
                 {
                       SendEmail(from,password,to,subj,content);
                 }
         }
        catch (Exception ex)
        {
                //Catch: sendMails
        
}
}


public SendEmail(string From,string Password,string ToMail,string Sub,string Content)
{
      try
         {
                MailMessage mail = new MailMessage();
                MailAddress fromMail = new MailAddress(From);
                mail.From = fromMail;
                mail.To.Add(ToMail);
                SmtpClient client = new SmtpClient("smtpout.xxx.net");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Port = 25;
                client.Host = "smtpout.xxx.net";
                client.EnableSsl = false;
                mail.Subject = strSubject;
                mail.Body = strBody;
                mail.IsBodyHtml = true;
                client.Credentials = new System.Net.NetworkCredential(strFrom, Pass);
                client.Send(mail);                //Stops here but not catch by Catch: SendMails its catch by Catch: HERE and shows null refrence at sendMails(dt)
                                                     
Only this happened, when To address is not existing (eg: karthikeyanmlp123789@gmail.com (not registered but valid mail format))
         }

        catch (Exception ex)
        {
                //Catch: SendMails
        }
}

Note: I am not use
throw inside any catch

 

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Scheduler did'nt Catch the  Inner Catch while ErrorsScheduler did'nt Catch the Inner Catch while Errors


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out