Log in to see Cloud of Tags

Wealth-Lab Wiki

AlertByEmail

RSS

Syntax

public static void SendEmail(this EmailAlertParams param, string To, string MessageSubject, string MessageText)
public EmailAlertParams(string from, string smtpServer, int port, string login, string pass, bool secure)

public AlertByEmail( string from, string smtpserver, int port, string pass, bool secure ) public void SendEmail( string To, string Subj, string Msg )

Parameter Description

paramAn EmailAlertParams instance with STMP server parameters
fromSender E-mail address
smtpServerSMTP server
portSMTP server port
passSMTP server password
secureSecure connection (true = enabled, false = disabled)
(optional) loginUse this only when your SMTP login is different from your email address.
ToDestination e-mail address
MessageSubjectMessage subject
MessageTextMessage body

Description

Note: Wealth-Lab 6 has Email Alerts natively. Open Preferences - Email Alerts to set up your email account and start receiving Strategy alerts. "AlertByEmail" helps you send customized messages.

By virtue of .NET, it's possible to send e-mail in WL6 from the Strategy code. This code illustrates how to do it using a secure (SSL) mail server (e.g. Google).

First, create an instance of the EmailAlertParams class in the Strategy code like shown below, passing the essential parameters like sender e-mail and SMTP server credentials and port. Then call SendEmail, passing destination e-mail address and the message subject and text.

Note: if using Gmail, you might need to Allow less secure apps to access your account. Effective February 15, 2021, AlertByEmail will stop working for G Suite accounts (ex Google Apps for Domains) because Google will retire access for Less Secure Apps on that date.

Example

Example using C# extension methods:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { public class TestEmail : WealthScript { protected override void Execute() { string From = "your.email@gmail.com"; string SmtpServer = "smtp.gmail.com"; int Port = 587; string Pass = "yourpassword"; bool Secure = true; EmailAlertParams param = new EmailAlertParams( From, SmtpServer, Port, Pass, Secure ); param.SendEmail( "another.address@gmail.com", "Hello World!", "E-mail generated by Wealth-Lab 6" ); } } }

Legacy syntax example:

First, create an instance of the class in the Strategy code like shown below, passing the essential parameters like sender e-mail and SMTP server credentials and port. Then call SendEmail, passing destination e-mail address and the message subject and text.


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

namespace WealthLab.Strategies { public class TestEmail : WealthScript { protected override void Execute() { string From = "your.email@gmail.com"; string smtpServer = "smtp.gmail.com"; int Port = 587; string Pass = "yourpassword";

AlertByEmail mail = new AlertByEmail( From, smtpServer, Port, Pass, true ); mail.SendEmail( "another.address@gmail.com", "Hello World!", "E-mail generated by Wealth-Lab 5" ); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.