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
Easylanguage to email screen shot
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Easylanguage to email screen shot
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.
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.
Re: Easylanguage to email screen shot
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
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
Exe File
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
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;
}
}
}