已阅读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年重庆安全技术职业学院单招职业技能测试题库附答案
- 2025年宝鸡麟游县殡仪馆及公益性公墓招聘(10人)笔试考试备考题库及答案解析
- 2025年黑龙江省公务员《申论(行政执法)》试题含答案
- 2025黑龙江鸡西兴凯物业管理有限公司招聘区属国有企业中层管理人员7人考试参考题库附答案解析
- 2025江苏镇江市京口产业投资发展集团有限公司招聘2人备考题库附答案详解(轻巧夺冠)
- 福建省福州市仓山区2024-2025学年三年级上学期期末数学试题
- 中医特色护理在急诊科的应用
- DB35T 2285-2025 低零碳工厂建设导则
- 新安全生产法2025年版全文
- 高层建筑火灾避险自救逃生学习课件
- 贵州茅台股份有限公司财务绩效分析
评论
0/150
提交评论