带有多个附件的电子邮件发送 [英] email send with multiple attachment

查看:149
本文介绍了带有多个附件的电子邮件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,但是我需要此用户名和密码
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.com");
    MailAddress mailto = new MailAddress("receiver@abc.com");
    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.com", 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.


这篇关于带有多个附件的电子邮件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆