带有多个附件的电子邮件发送

编程入门 行业动态 更新时间:2024-10-27 19:29:43
本文介绍了带有多个附件的电子邮件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

很抱歉,但是我需要此用户名和密码 smtp.Credentials =新的NetworkCredential(用户名",密码"); 我在哪里以及如何获得它..... //代码如下,只向我解释一行 //这行代码的参数是什么 //我将在何处获得此用户名和密码 //smtp.Credentials = new NetworkCredential("username","password");

sory but i need user name and password for this smtp.Credentials = new NetworkCredential("username","password"); where and how can i get that..... //The code is as follows just explain me one line //what will be the parameters for this line of code //where will i get the user name and password for this // smtp.Credentials = new NetworkCredential("username","password");

button_click() { MailAddress mailfrom = new MailAddress("sender@gmail"); MailAddress mailto = new MailAddress("receiver@abc"); MailMessage newmsg = new MailMessage(mailfrom, mailto); newmsg.Subject = "Subject of Email"; newmsg.Body = "Body(message) of email"; //For File Attachment, more file can also be attached Attachment att = new Attachment("C:\\...file path"); newmsg.Attachments.Add(att); SmtpClient smtp = new SmtpClient("smtp.gmail", 587); smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("username","password"); smtp.EnableSsl = true; smtp.Send(newmsg); }

------- dhanyabaad

-------dhanyabaad

推荐答案

Attachments属性是Attachment对象的集合.只需不断添加它们,直到完成. The Attachments property is a collection of Attachment objects. Just keep adding them until you''re done.

请尝试使用多个文件附件. 使用此代码: Please Try Multiple File Attachment. Using This Code: MailMessage newmsg = new MailMessage(mailfrom, mailto); string[] FileName = new string[] {"File1","File2" }; foreach (string File in FileName) { Attachment atch = new Attachment(File); newmsg.Attachments.Add(atch); }

向您的smtp服务器管理员(可能与您的网络管理员一起)询问所需的帐户详细信息. Ask your smtp server administrator (possibly in conjunction with your network administrator) for the account details required.

更多推荐

带有多个附件的电子邮件发送

本文发布于:2023-05-27 19:34:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/300593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file 'D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!