unity 3D - 如何填写表格并将其发送到电子邮件地址

时间:2015-02-07 22:10:23

标签: forms

我有Android和iOS的应用程序 我想填写表格并将其发送到电子邮件地址 基本上,这是获得一些反馈。

但首先,有可能吗?

非常感谢。

1 个答案:

答案 0 :(得分:1)

假设您正在使用C#,是的,这是可能的。

This SO question可能会对您有所帮助。 One of the answers claim to have a working code如下:

  

我刚刚使用以下代码成功发送了来自Unity 3D的电子邮件:

using System.Net;
using System.Net.Mail;

using UnityEngine;

public class SendMail : MonoBehaviour {
    public string sender = "me@mymailaccount.com";
    public string receiver = "me@mymailaccount.com";
    public string smtpPassword = "mysmtppassword";
    public string smtpHost = "mail.mymailacount.com";

    // Use this for initialization
    private void Start() {
        using (var mail = new MailMessage {
            From = new MailAddress(sender),
            Subject = "test subject",
            Body = "Hello there!"
        }) {
            mail.To.Add(receiver);

            var smtpServer = new SmtpClient(smtpHost) {
                Port = 25,
                Credentials = (ICredentialsByHost)new NetworkCredential(sender, smtpPassword)
            };
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            smtpServer.Send(mail);
        }
    }
}