Easylanguage to email screen shot

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Westsider
Posts: 12
Joined: 13 Dec 2012
Has thanked: 2 times
Been thanked: 4 times

Easylanguage to email screen shot

Postby Westsider » 10 May 2016

Hi there,
Does anyone know how to use EL to mail a screenshot? I dont see anything here but thought I would ask.

Sincerely,
Westsider

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2732 times

Re: Easylanguage to email screen shot  Topic is solved

Postby Henry MultiСharts » 11 May 2016

Hello Westsider,

You can use ShellExecute to run an app/dll that will do a screenshot and email it for you.
Here is the ShellExecute.pla sample.

Westsider
Posts: 12
Joined: 13 Dec 2012
Has thanked: 2 times
Been thanked: 4 times

Re: Easylanguage to email screen shot

Postby Westsider » 11 May 2016

WOW!!!!! Thanks Henry!!!!
I've always suspected I could do this from inside a pla but never tried it. This is a great solution and I'll write an app in VS to do what I need.

Cheers,
Westsider

Westsider
Posts: 12
Joined: 13 Dec 2012
Has thanked: 2 times
Been thanked: 4 times

Exe File

Postby Westsider » 12 May 2016

Here is the C# exe file I wrote in Visual Studio. You would have to replace your email address and mail client then compile it and finally point the .pla that Henry wrote -

ShellExecute.pla sample

referenced in the above post to the compiled exe on your hard drive.

Westsider

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;

using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Reflection;
using System.Windows.Forms;


namespace MailScreenShot
{
    class Program
    {
        static void Main(string[] args)
        {
            // Capture the screen to a stream
            Bitmap memoryImage = new Bitmap(SystemInformation.VirtualScreen.Width,
                                SystemInformation.VirtualScreen.Height,
                                PixelFormat.Format64bppArgb);       
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);
            memoryGraphics.CopyFromScreen(SystemInformation.VirtualScreen.X,
                                       SystemInformation.VirtualScreen.Y,
                                       0,
                                       0,
                                       SystemInformation.VirtualScreen.Size,
                                       CopyPixelOperation.SourceCopy);
            System.IO.Stream stream = new System.IO.MemoryStream();
            memoryImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
            stream.Position = 0;

            // send mail
            string to = "yourname@yourisp.com";       //  Replace with your email address
            string from = "yourname@yourisp.com";   //  Replace with your email address
            MailMessage message = new MailMessage(from, to); 
            message.Subject = "TS";
            message.Body = @"Trade Alert";
            Attachment attach = new Attachment(stream, "MyImage.Jpeg");
            message.Attachments.Add(attach);
            SmtpClient client = new SmtpClient("Your Mail Client");   // Replace with your email client
            // Credentials are necessary if the server requires the client
            // to authenticate before it will send e-mail on the client's behalf.
            client.UseDefaultCredentials = true;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",
                            ex.ToString());
            }
            return;
        }
    }
}


Return to “User Contributed Studies and Indicator Library”