如何用unity3d实现发送带附件的邮件

明天丶你好 2014-05-27 04:36:10
如何用unity3d实现发送带附件的邮件?求详细的代码!
...全文
1741 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Bricke 2015-04-02
  • 打赏
  • 举报
回复
503 Error: need EHLO and AUTH first !
l709299494 2014-12-16
  • 打赏
  • 举报
回复
求unity发布安卓版的发邮件
LeungWt 2014-06-13
  • 打赏
  • 举报
回复
这个好,赞一个,学习了。
jcf03722 2014-06-07
  • 打赏
  • 举报
回复
顶一下,拿分走人
  • 打赏
  • 举报
回复
引用 楼主 chao_qiu123 的回复:
如何用unity3d实现发送带附件的邮件?求详细的代码!
以Gmail为例。 点击屏幕的Capture按钮得到当前屏幕截图,点击Send按钮将之前的截图作为附件发送邮件。

using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
 
public class TryDemo : MonoBehaviour {
 
    // Use this for initialization
    void Start () {
 
    }
     
    // Update is called once per frame
    void Update () {
     
    }
 
    void OnGUI() {
        if (GUI.Button(new Rect(0, 50, 100, 40), "Capture")) {
            Debug.Log("Capture Screenshot");
            Application.CaptureScreenshot("screen.png");
        }
        if (GUI.Button(new Rect(0, 0, 100, 40), "Send")) {
            SendEmail();
        }
    }
 
    private void SendEmail()
    {
        MailMessage mail = new MailMessage();
         
        mail.From = new MailAddress("youraddress@gmail.com");
        mail.To.Add("youraddress@qq.com");
        mail.Subject = "Test Mail";
        mail.Body = "This is for testing SMTP mail from GMAIL";
        mail.Attachments.Add(new Attachment("screen.png"));
         
        SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
        smtpServer.Port = 587;
        smtpServer.Credentials = new System.Net.NetworkCredential("youraddress@gmail.com", "yourpassword")as ICredentialsByHost;
        smtpServer.EnableSsl = true;
        ServicePointManager.ServerCertificateValidationCallback = 
            delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
        { return true; };
 
        smtpServer.Send(mail);
        Debug.Log("success");
    }
}
建议楼主以后用英文Google搜索。

29,049

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧