- Home /
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..
Answer by XienDev · Mar 20, 2013 at 07:32 AM
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....?
Answer by Deniz2014 · Mar 13, 2018 at 05:33 PM
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.
Answer by Mayank516 · Sep 22, 2021 at 06:22 PM
You can use the following plugin from asset store for iOS and android. Plugins are cheap and developer provides really nice support.
ANDROID: https://assetstore.unity.com/packages/tools/integration/email-composer-in-android-109359
Your answer
Follow this Question
Related Questions
Take a Screen Shot and attach it with a mail 2 Answers
Texture2d.readPixels not working with iOS 6 3 Answers
How to get banner ad's screenshot to a texture? 0 Answers
Using Texture2D.GetPixels() to take a screenshot and then show it on an Image - iOS problems. 1 Answer
Capturing 360 Image causes to darken the image and show ghosting and artifacts 0 Answers