NexusFi: Find Your Edge


Home Menu

 





Alternative to SendMail ()


Discussion in NinjaTrader

Updated
    1. trending_up 4,665 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 pequemec 
Elche, Spain
 
Experience: None
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: ES
Posts: 14 since Jul 2009
Thanks Given: 6
Thanks Received: 1

Hello,

I need an alternative to SendMail () in NinjaTrader. Events:

1. I´ve download Mail.dll from Lesnikowski .NET components.
2. I clicked right mouse button in the NinjaScript Editor and selected the NinjaScript menu name "References…"
3. In the "References…" window, button dialog "Add…"
4. I have selected Mail.dll
5. Also I added using declarations:

using Lesnikowski.Client;
using Lesnikowski.Client.IMAP;
using Lesnikowski.Mail;
using Lesnikowski.Mail.Fluent;
using Lesnikowski.Mail.Headers;
using Lesnikowski.Mail.Headers.Constants;

6. The logic of the indicator is as follows:
 
Code
namespace NinjaTrader.Indicator
{
    public class emailer : Indicator
    {	
	#region Variables
        private const string _server = "smtp.gmail.com";
	private const int _port = 465;
        private const string _user = "[email protected]";
        private const string _password = "xxxxxxx";
	private const string _to = "[email protected]";
		
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            Overlay	= true;
        }
	protected override void OnStartUp()
	{
	    Main();
	}
		
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
        //Example:
			if (CurrentBar < 3)
				return;
			
			if (Close[0] > Close[3])
			{
				CandleOutlineColor = Color.Gold;
				BarColor = Color.Gold; 
			}
			else
			{
				CandleOutlineColor = Color.Empty;
				BarColor = Color.Empty;
			}			
	}
			
        static void Main()
			
        {
            // Use builder class to create new email
            MailBuilder builder = new MailBuilder();
            builder.From.Add(new MailBox(_user, "Alice"));
            builder.To.Add(new MailBox(_to, "Bob"));
            builder.Subject = "Test indicator";
            builder.SetTextData("This is plain text message.");

            IMail email = builder.Create();

            // Send the message
            using (Smtp smtp = new Smtp())
            {
                smtp.ConnectSSL(_server, _port);
                smtp.Ehlo();
                smtp.Login(_user, _password);

                smtp.SendMessage(email);

                smtp.Close();
            }
        }	
   }
}
7. No errors in compile mode.
8. The logic run in Visual Studio 2010 but not run in NinjaTrader, error in output window:

Error on calling 'OnStartUp' method for indicator 'emailer': Los controladores AssemblyResolveEvent no pueden devolver ensamblados cargados sólo para reflexión.
more info here Resolver cargas de ensamblado (but I do not understand)

9. Please, anyone can help me or know a better solution?

Thanks in advance.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Prop Firm Tracked Payouts Hit $115M in Q1 but Growth Fla …
Funded Trading Evaluation Firms
US Treasury Weighs Direct Oil Futures Market Interventio …
Commodities
SEC Advisory Committee Backs Tokenized Securities Exempt …
Traders Hideout
Kalshi Rockets to $22B, Passes Polymarket in Volume -- B …
Prediction Markets & Event Contracts
Probability Collapse: Bitcoin $150k Craters from 15% to …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557


I did a quick look at the translation, it seems it might have something to do with a protected assembly since it is mentioning Reflection.

Why use this third party library? Have you looked at System.Net.Mail?

System.Net.Mail Namespace ()

It might also be helpful if you told us why you need an alternative to the built-in SendMail() function.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 pequemec 
Elche, Spain
 
Experience: None
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: ES
Posts: 14 since Jul 2009
Thanks Given: 6
Thanks Received: 1

Thank you very much.

The code above is an example. Maybe I expressed myself badly, I want to program a function "ReceiveMail()" for read the subject of an email and enter the signal in the chart. Mail.dll has this feature but System.Net.Mail not. Another solution?

Best regards.


Started this thread Reply With Quote
  #5 (permalink)
 pequemec 
Elche, Spain
 
Experience: None
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: ES
Posts: 14 since Jul 2009
Thanks Given: 6
Thanks Received: 1

I will consult the creator of Mail.dll


Started this thread Reply With Quote




Last Updated on September 5, 2011


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts