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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      66 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      141 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      76 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      47 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X