我将邮件excel文件发送到我的邮箱 [英] I send mail excel file to my mail

查看:173
本文介绍了我将邮件excel文件发送到我的邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于该代码如下



For that code as follows

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("rajesh@gmail.com");
mail.To.Add("sathish@gmail.com");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(@"C:\Users\551386\Desktop\DataDump\Excel.xls");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("rajesh@gmail.com", "12345");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);





当我执行上面的代码时显示错误如下



发送邮件失败

以上错误显示如下以下





when i execute the above code shows error as follows

Failure sending mail
the above error shows in below line as follows

SmtpServer.Send(mail);







请帮我解决错误是什么我的上述代码。



我尝试过:



i发送邮件excel文件到我的邮件



当我执行上面的代码时显示错误如下



发送邮件失败

以上错误如下所示:






please help me what is the mistake in my above code.

What I have tried:

i send mail excel file to my mail

when i execute the above code shows error as follows

Failure sending mail
the above error shows in below line as follows

SmtpServer.Send(mail);

推荐答案

请看一下这个解决方案:

< a href =http://stackoverflow.com/questions/4468985/sending-email-fails-in-c-sharp-3-5> .net - 在C#3.5中发送电子邮件失败 - Stack Overflow [ ^ ]
Please have a look at this solution:
.net - sending email fails in C# 3.5 - Stack Overflow[^]


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

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