Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sending email from inside a script.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Sending email from inside a script.

    Hi

    I wanted to develope an indicator that has an email function. Using System.Net.Mail, with the following code:-

    Code:
    MailMessage mail1 = new MailMessage("[email protected]", "[email protected]");
    			SmtpClient client1 = new SmtpClient();
    			client1.Port = 465;
    			client1.Credentials = new System.Net.NetworkCredential("[email protected]","1234");
    			client1.DeliveryMethod = SmtpDeliveryMethod.Network;
    			client1.UseDefaultCredentials = false;
    			client1.Host = "smtp.email.com";
    			client1.EnableSsl = true;
    			
    			mail1.Subject = "this is a test email 12345.";
    			mail1.Body = "this is my test email body 12345";
    			client1.Send(mail1);
    But when I use this NT freezes up, is there a reason for this, is it not a good idea to try and do this?

    #2
    GKonheiser, how often / when would you trigger the sending? I would just recommend to use our default SendMail() NinjaScript methd for this task.

    Comment


      #3
      Hi Bertrand,

      OK I will use the built in method. I am having a problem with one of my installations of NT and sending a test email. On one machine test email is sent without a problem, on my second install I cant get a test email to be sent. Always getting timeouts. I've tried two different accounts. Is there a way to debug this from a more detailed log?

      Comment


        #4
        GKonheiser, if this is isolated for both accounts to a specific machine, I would first check into the firewall setup here and compare. A first quick test would be just deactivating all filtering rules and recheck.

        Comment


          #5
          It was the stupid windows firewall : ). Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          82 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          43 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          64 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          68 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          56 views
          0 likes
          Last Post CarlTrading  
          Working...
          X