- Home /
How to add a Screenshot as Attachment?
Hello,
i want to create a Email with a Screenshot as Attachment.
I create the screenshot like this:
Application.CaptureScreenshot(attachmentFileName);
And i send the mail like that:
//Mail Data
private string fromAddress = "asd@gmail.com";
private string toAddress = "asddd@outlook.com";
private string subject = "Bug Report";
private string smtpServer = "smtp.gmail.com";
private int port = 587;
private string credentialMail = "asd@gmail.com";
private string credentialPass = "asd";
private string attachmentFileName = "Screenshot.png";
public void SendEMail()
{
MailMessage email = new MailMessage();
email.From = new MailAddress(fromAddress);
email.To.Add(toAddress);
email.Subject = subject;
email.Body = "This is for testing SMTP mail from GMAIL";
email.Attachments.Add (new Attachment (attachmentFileName));
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = port;
smtpServer.Credentials = new System.Net.NetworkCredential(credentialMail, credentialPass) as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(email);
Debug.Log("success");
}
Anyone has a idea? Thanks!
Comment
Answer by rajavamsidhar_gvs · Aug 13, 2015 at 07:50 AM
see in that link..once do google for this. nice question too. try this if it works?
Application.OpenUrl("mailto:?subject=subject&body=bodytesting&Attachment="+Application.persistentDataPath+ "\\screenShot.png");
Your answer
