Sending email with attachment

Hi all,

I just wanted to send an email through unity with the screenshot of the screen(iPad screen) as attachment.

Currently I came across to this for emailing :

           Application.OpenURL("mailto:?subject=subject&body=bodytesting");

Also I am using ReadPixels for saving my screenshot.

So please help me here with forwarding the screenshot as attachment.

thanks in advance…

3 Answers

3

a)
With Unity 2017 I had to replace the obsolete Application.CaptureScreenshot
with ScreenCapture.CaptureScreenshot(Application.persistentDataPath + “\bug.png”);
screenshot on pc confirmed in C:\Users\username\AppData\LocalLow\packagename\gamename
With Android I used ScreenCapture.CaptureScreenshot(“bug.png”); which placed
the file into the package folder


b)
Application.OpenUrl("mailto:?s …
opened gmail on android with subject and body but did not add the Attachment - maybe a security feature?
I put several file types (zip, png, txt) in the Application.persistentDataPath to attach but none worked

If you store the image / attachment in a private folder of your application the email app of course can't access the file as only your app is allowed to write or read this folder. You have to store the image at a location where the email app can reach it. Though i never tested it.

–

You can use the following plugin from asset store for iOS and android. Plugins are cheap and developer provides really nice support.

iOS : Email Composer in iOS | Integration | Unity Asset Store

ANDROID: Email Composer For Android | Integration | Unity Asset Store

  1. save screenshot to file:

    Application.CaptureScreenshot(Application.persistentDataPath + “\screen.png”);

  2. Open url with attachment :

    Application.OpenUrl(“mailto:?subject=subject&body=bodytesting&Attachment=”+Application.persistentDataPath+ “\screen.png”);

Hi XienDev, I tried using the above code....but XCode show me the this error while debugging.. Failed to store screen shot.... Can u tell why is this happening....?

–