Unity 跨平台发送
来源:互联网 发布:一元购平台源码 编辑:程序博客网 时间:2024/06/03 23:39
公司项目需求要求将客户的问题反馈发送到公司邮箱中,在网上查询后发现需要修改一些地方;
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using UnityEngine.UI;
using System.Security.Cryptography.X509Certificates;
public class Text1 : MonoBehaviour
{
public Text t;
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("1245651651@qq.com");//发送邮件的邮箱号;
mail.To.Add("1245651651@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.qq.com");//选择服务器这里是qq
smtpServer.Credentials = new System.Net.NetworkCredential("1245651651@qq.com", " 授权码") as ICredentialsByHost;//这里面的授权码是需要去邮箱中设置的,详细设置见下图
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
try
{
smtpServer.Send(mail);//发送邮件
t.text = "Succeres";
}
catch(Exception)
{
Exception e=new Exception();
t.text = e.Message;
}
}
}
如果需要在手机品台上发送邮件,
需要注意的是在playersetting中需要设置api level 为.net2.0 (.net2.0 subset不支持)- Unity 跨平台发送
- unity 跨平台的原理
- 【转】unity跨平台文件操作详解
- Unity发送邮件功能
- Unity平台宏定义
- unity平台的预处理
- Unity 平台区分
- unity 平台检测
- Unity区分平台编译
- unity平台的预处理
- unity平台的预处理
- unity 平台控制宏
- unity平台的预处理
- unity平台的预处理
- {Unity} 平台预定义
- unity平台的预处理
- unity平台的预处理
- unity平台相关宏
- 关于C++ 前置声明的说明
- linux c 创建多级目录接口实现
- TypeError: must be str, not bytes
- [Unity][安卓]Unity Android SDK配置
- 十进制与其它进制(整数)转换编程
- Unity 跨平台发送
- 图片框架Fresco
- 数组元素的访问-----指针
- struts2文件上传和下载
- perl 脚本里调用shell 以及获取返回值
- 机器学习基础03-矩阵和线性代数
- Atom系列(一) -- 不要太棒的21世纪编辑器
- AndroidStudio3.0 下载使用新功能介绍
- 理解 LSTM 网络