- Home /
Mailto with attachment
Application.OpenURL("mailto:?subject=test&body=test&attachment=" + filePath);
it does open the mail program, but do not include the file. Am I doing something wrong? There's any way to do that with unity?
Answer by ArkaneX · Aug 21, 2013 at 10:33 PM
Standard mailto protocol does not support attachments (see specification).
If I'm not wrong, attachment support was provided by Microsoft in older MS Outlook versions, but in newer versions RFC compliant protocol is implemented.
Thanks for the fast answer. Do you see any alternative to create a new email in the default mail program with an atached file?
It depends what you require. If you need to launch client program, so that your user mail account and his/her mail server is used, then without control over this program you can't add any attachment automatically.
If, on the other hand, you don't have to display anything and just send the message using mail account provided by you, then you should be able to add an attachment. Please take a look at answer to this question.
To include attachment, you have to add the following lines to the code from above answer:
string attachmentPath = @"C:\somefile.txt";
System.Net.$$anonymous$$ail.Attachment attachment = new System.Net.$$anonymous$$ail.Attachment(attachmentPath);
mail.Attachments.Add(attachment);
There's an important issue related to the ServicePoint$$anonymous$$anager.ServerCertificateValidationCallback used in the code. Basically, it is a way of preventing the certificate errors during access to hosts via SSL. Using it is unsafe, at least in the form from linked code, so that it always return true, ignoring all errors. If you're going to play with this code, you definitely have to read about this callback.
And finally - if callback will be used, it should be initialized once, for example in Awake method of some global object.
That's only a partial example from another post. The mail.Attachments is from the $$anonymous$$ail$$anonymous$$essage class, so it won't work with the Ops question. You forgot to add the most important part. $$anonymous$$ail$$anonymous$$essage mail = new $$anonymous$$ail$$anonymous$$essage(); and use smtp not mailto:
Answer by johnbrisoff236 · Oct 27, 2013 at 06:16 PM
Work with ms outlook data with the aid of .pst repair tool outlook 2007 download
Article http://www.outlook.repairtoolboxx.com/how-to-repair-outlook.html must immediately aid you
Your answer
Follow this Question
Related Questions
Turn off renderer on key press 1 Answer
Application.OpenURL causing crashes on Android? 0 Answers
Visual studio can't attach to unity editor. 7 Answers
Application.OpenURL not working in tvOS? 1 Answer
Callback for debugger attached state change (like EditorApplication.playModeStateChanged)? 0 Answers