Screenshot Button Click

Hi all,

I have been developing an app to use on android devices that can immensely improve my business performance and I have been trying to add a button that once clicked takes a screenshot of the current screen and then saves it into either the internal storage or external SD.

I have been looking into the below only to get the following error but I cannot see why, I have been looking for ages, any help would be greatly appreciated…

Assets\Scripts\CaptureScreen.cs(10,17): error CS1002: ; expected

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public void takeScreenshot()
{

uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE";

{
    Date now = new Date();
    android.text.format.DateFormat.format("dd-MM-yyyy_hh:mm:ss", now);

    try {
        // image naming and path  to include sd card  appending name you choose for file
        String mPath = Environment.getExternalStorageDirectory().toString() + "/storage/extSdCard/Job" + now + ".jpg";

        View v1 = getWindow().getDecorView().getRootView();
        v1.setDrawingCacheEnabled(true);
        Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
        v1.setDrawingCacheEnabled(false);

        File imageFile = new File(mPath);

        FileOutputStream outputStream = new FileOutputStream(imageFile);
        int quality = 100;
        bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
        outputStream.flush();
        outputStream.close();

        openScreenshot(imageFile);
    } catch (Throwable e)

    {
        // Several error may come out with file handling or DOM
        e.printStackTrace();
    }
}
}

Since posting the above I had another idea which I thought I would ask.

The idea of the above is to have a button that once clicked takes a snapshot of whatever is on the screen where the button is and saves it locally on the android device, I have just also found some old code I used in another app to send an -email with a message when clicking a button, I remember this working but what if instead of it sending a message, it takes the screenshot and then e-mails the shot as jpg directly. Any help would be greatly appreciated.

  public void SendReceipt()
    {
        MailMessage mail = new MailMessage();

        mail.From = new MailAddress("my email here");
        mail.To.Add("my email here");
        mail.Subject = "Receipt";
        mail.Body = "Hello World";

        SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
        smtpServer.Port = ;
        smtpServer.Credentials = new System.Net.NetworkCredential("my email here", "my password here") as ICredentialsByHost;
        smtpServer.EnableSsl = true;
        ServicePointManager.ServerCertificateValidationCallback =
        delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        { return true; };
        smtpServer.Send(mail);
        Debug.Log("success");

    }

Bump