ASP.NET邮件问题 [英] ASP.NET mail problem

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

问题描述

嗨.我一直在尝试从Windows 7平台上的ASP.NET应用程序发送电子邮件.我安装了IIS7,并配置了SMTP部分,但无济于事.我试图在Internet上查找问题,但找不到解决方案.它说``无法建立连接,因为目标计算机主动拒绝了127.0.0.1:25''

Hi. I have been trying to send en email from an ASP.NET application on a Windows 7 platform. I installed IIS7 and configured the SMTP section but to no avail. I tried hard looking my problem in the internet but i cant find the solution.its saying ''No connection could be made because the target machine actively refused it 127.0.0.1:25''

SmtpClient client = new SmtpClient("127.0.0.1", 25);
MailMessage message = new MailMessage("no-reply@test.com", "markspiteri1@gmail.com", "Subject subbbbb", "bodyy");
client.Send(message);



谢谢您的帮助.thx



I would rly appreciate ur help.thx

推荐答案

查看此链接

尝试一下...

try this...

string subject = "mention subject here";
        try
        {
            
            string emailTo = "uremail";
            string emailfrom="uremail";
            string body = "urbody";
            MailMessage objmail = new MailMessage(emailfrom, emailTo, subject,body);
 

            SmtpClient smtpclnt = new SmtpClient("smtp.gmail.com", 587);
            smtpclnt.DeliveryMethod = SmtpDeliveryMethod.Network;
 
            smtpclnt.UseDefaultCredentials = true;
            smtpclnt.EnableSsl = true;
            smtpclnt.Credentials = new System.Net.NetworkCredential("username", "password");
            smtpclnt.Send(objmail);
        }
        catch (Exception ex)
        {
           
        }


这可能会有所帮助,

在IIS 7上设置SMTP并使用C#发送电子邮件 [
It might be helpful,

Setting up SMTP on IIS 7 and Send Email using C# [^]

:)


这篇关于ASP.NET邮件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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