- Home /
Question by
siddharth3322 · Oct 01, 2014 at 07:18 AM ·
emailsocialattachment
Send email with attachment
For my game, I want to send image with email. At present I have used following code. It creates mail template but didn't attach image with mail.
public void OnEmailButtonClick ()
{
Debug.Log ("Email Button Click");
string email = "me@example.com";
string subject = MyEscapeURL("My Subject");
string body = MyEscapeURL("My Body\r\nFull of non-escaped chars");
string pngName = fileName (Screen.width, Screen.height);
Application.CaptureScreenshot (pngName);
string attachment = Application.persistentDataPath + "/" + pngName;
Debug.Log("attachment : " + attachment);
Application.OpenURL("mailto:" + email + "?subject=" + subject + "&body=" + body + "&attachment=" + attachment);
}
string fileName (int width, int height)
{
return string.Format ("feedmachi_screen_{0}x{1}_{2}.png",
width, height,
System.DateTime.Now.ToString ("yyyy-MM-dd_HH-mm-ss"));
}
I can't able to find my mistake in above code. I want to attach image with mail.
Comment
message.Attachments.Add(new Attachment(attachmentFilename));
I don't use your suggest way for send mail. So from that link I don't get anything anyway for your reply.
Asked many times. You can't attach a file using the mailto protocol (check this answer). You'll need a workaround (depending mostly on the platform).
Answer by unimechanic · Oct 01, 2014 at 03:02 PM
This question is duplicated, find answers here:
http://answers.unity3d.com/questions/521066/mailto-with-attachment.html