




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 情商口才课件
- 兴义市第八中学2026届高一化学第一学期期中质量跟踪监视试题含解析
- 活动方案策划稿
- 2026届浙江省杭州市江南实验学校高三化学第一学期期末达标测试试题含解析
- 怎么写食品安全活动方案
- 泡沫雕塑面试题及答案
- 小学汉字之谜社团活动方案
- 军事投弹考试题及答案
- 化学考核面试题及答案
- 家电公司配送管理规定
- 煤矿安全规程新旧版本对照表格版
- 私募薪酬管理办法
- 2025年急诊三基考试题库及答案
- 2025贵州航空产业城集团股份有限公司旗下子公司贵州安立航空材料有限公司招聘61人笔试历年参考题库附带答案详解
- 军人休假规定管理办法
- 2025秋人教版英语八年级上Unit 2 全单元听力材料文本及翻译
- DB11-T 1455-2025 电动汽车充电基础设施规划设计标准
- 2025北京初二(上)期末英语汇编:阅读单选CD篇
- 2025年公招教师特岗教师招聘考试教育公共基础知识真题(带答案)
- 2025年贵州省中考英语真题含答案
- 消除医疗歧视培训
评论
0/150
提交评论