




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
在Unity中发送邮件带图片的三种方式(C#脚本)(同时发多人不同邮件)1,在正文中插入图片发送usingUnityEngine;usingSystem.Collections;usingSystem.Net.Mail;usingSystem.Net;usingSystem;usingSystem.IO;publicclass SendMessage : MonoBehaviour string path =; / Use this for initialization void Start () / Update is called once per frame void Update () void OnMouseDown() stringreceiverName =receiverName; stringreceiverEmail =receiverEmail; stringsenderName =senderName; stringsenderEmail =senderEmail; path =Application.dataPath +/test.png; /截屏存储路径 Application.CaptureScreenshot(path); Debug.Log(path); /函数调用 SendEmail(receiverName,receiverEmail,senderName,senderEmail); publicvoid SendEmail(stringreceiverName,string receiverEmail,string senderName,string senderEmail) MailMessage mail= new MailMessage(); mail.From = new MailAddress(senderEmail); mail.To.Add(receiverEmail); mail.Subject = 标题; string htmlBody =文本文字; /传参 htmlBody += receiverName; htmlBody +=    ; htmlBody +=; /first we create the Plain Text partAlternateView plainView =AlternateView.CreateAlternateViewFromString(This is my plain text content, viewable by thoseclients that dont support html, null, text/plain); AlternateView htmlView =AlternateView.CreateAlternateViewFromString(htmlBody, null, text/html); /createthe LinkedResource (embedded image) LinkedResource picture = new LinkedResource(Application.dataPath+/test.png); picture.ContentId= companylogo; /add the LinkedResource to the appropriateview htmlView.LinkedResources.Add(picture); /add the views mail.AlternateViews.Add(plainView); mail.AlternateViews.Add(htmlView); SmtpClient client = newSmtpClient(); /specify the mail server address client.UseDefaultCredentials = false;client.Credentials = (ICredentialsByHost)new System.Net.NetworkCredential(senderEmail, password);client.DeliveryMethod = SmtpDeliveryMethod.Network;client.Send(mail); 2,以附件形式发送 using UnityEngine; using System.Collections; using System.Net.Mail; using System.Net; using System; using System.IO; publicclass SendMessage : MonoBehaviour publicstring path =; / Use this for initialization void Start () / Update is called once per frame void Update () void OnMouseDown() string customerName1 =receiverName; string customerEmail1 =receiverEmail; string saleaName1 =senderName; string salesEmail1=senderEmail; path =Application.dataPath +/test.png; /截屏函数 Application.CaptureScreenshot(path); Debug.Log(path); /函数调用 SendEmail(customerName1,customerEmail1,saleaName1,salesEmail1); publicvoid SendEmail(stringcustomerName,string customerEmail,stringsalesName,string salesEmail) System.Net.Mail.SmtpClientclient = new SmtpClient(); client.UseDefaultCredentials= false; client.Credentials= (ICredentialsByHost)new System.Net.NetworkCredential(salesEmail, password); client.DeliveryMethod= SmtpDeliveryMethod.Network; MailAddressaddressFrom = new MailAddress(salesEmail, salesName); MailAddressaddressTo = new MailAddress(customerEmail, customerName); System.Net.Mail.MailMessagemessage = new MailMessage(addressFrom, addressTo); message.Sender= new MailAddress(salesEmail); message.BodyEncoding= System.Text.Encoding.UTF8; message.IsBodyHtml= true; string mailBody = ; message.Body = mailBody; message.Subject= This is a test; message.Attachments.Add( new Attachment(Application.dataPath +/test.png ); message.Attachments0.ContentId=ewen; message.Attachments0.ContentType.Name=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 物资配送车队管理制度
- 2025年长春天然气有限责任公司校园招聘笔试备考题库及参考答案详解一套
- 瑜伽企业课程管理制度
- 甘肃少儿武术管理制度
- 瓷砖门市员工管理制度
- 生产企业培训管理制度
- 生产加工销售管理制度
- 生产技能培训管理制度
- 公园城市实践活动方案
- qa职责管理制度
- 北京市朝阳区招聘社区工作者笔试真题2024
- T/CNESA 1203-2021压缩空气储能系统性能测试规范
- T/CGMA 031003-2020一般用离心空气压缩机
- 2025年四年级下册美术期末测试题附答案
- 计量经济学知到智慧树期末考试答案题库2025年南开大学
- 2025至2030中国天文馆行业投资前景研究与销售战略研究报告
- 国开学习网《员工招聘与配置》形考任务1-4答案
- 手机使用课件
- 2025年对外汉语教师资格考试试卷及答案
- 急性心梗诊疗(2025指南)解读课件
- 2025年观光车和观光列车司机N2证考试笔试试题(100题)含答案
评论
0/150
提交评论