Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

send email or text message

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

    send email or text message

    I want to send an email or text message to me when some conditions are met in a strategy. Here is the code. I did replaced with my email address and password and did try both smtp port. However, I didn't receive any email once I disconnected the live connection. How to debug what is wrong?

    private void SendEmailAlert()
    {
    try
    {
    using (SmtpClient smtp = new SmtpClient())
    {
    smtp.Host = "smtp.mail.yahoo.com";
    //smtp.Port = 587;
    smtp.Port = 465;
    smtp.EnableSsl = true;
    smtp.Credentials = new System.Net.NetworkCredential("email address ", "password");

    MailMessage message = new MailMessage();
    message.From = new MailAddress("email address");
    message.To.Add(EmailAddress);
    message.Subject = "NinjaTrader Connection Alert";
    message.Body = string.Format("Connection lost at {0}", Time[0]);

    smtp.Send(message);

    if (!string.IsNullOrEmpty(PhoneNumber))
    {
    message.To.Clear();
    message.To.Add(PhoneNumber + "@vtext.com");
    smtp.Send(message);
    }
    }
    }
    catch (Exception ex)
    {
    Print("Error sending email alert: " + ex.Message);
    }
    }​
    Last edited by Playdc; 02-28-2025, 01:03 PM.

    #2
    I find the solution for sending email. You need to yahoo app password instead of your normal password. You need to get one after logging into your yahoo account, then go to security setting to generate yahoo app password.

    Comment


      #3
      Hello Playdc,

      Glad you were able to work it out.

      The forum post below is a good reference.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

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