使用system.net.mail的smptp邮件 [英] smptp mail using system.net.mail

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

问题描述



我想在asp.net中编写邮件代码,我这样写代码:

Hi,,

I want to write code for mails in asp.net, i wrote code like this:

MailMessage msg = new MailMessage();
msg.To.Add(TextBox3.Text);
msg.From = new MailAddress("admin@ESCRIPT-001");
msg.Subject = "Registration Confirmation";
msg.Body = "Thanks For Registration,,................!!!!!!!";
//msg.Attachments.Add(new Attachment(Server.MapPath(".")+"\\ggg.txt"));
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
SmtpClient obj = new SmtpClient("ESCRIPT-001");
obj.Send(msg);
Response.Write("Registerd Successfully");



我的服务器名称是E-script001,域名是ganapathi,但是使用网络配置无法正常工作,请告诉我代码

在此先感谢



and my server name is E-script001 and domain name is ganapat but it''s not working by using web configuration please tell me code

Thanks In Advance

推荐答案

使用下面给出的代码,无论服务器是什么,它都可以正常工作:

MailMessage mailMessage = new MailMessage();
mailMessage.From ="abc@def.com";
mailMessage.To ="abc@xyz.com";
mailMessage.Subject =帐户创建成功!";
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.Body =任何文本"
mailMessage.Priority = MailPriority.High;
SmtpMail.SmtpServer ="127.0.0.1";
SmtpMail.Send(mailMessage);


阿努拉格
@cheers @
Use the code given below, whatever the server may be, it should work fine:

MailMessage mailMessage = new MailMessage();
mailMessage.From = "abc@def.com";
mailMessage.To = "abc@xyz.com";
mailMessage.Subject = "Account Created Successfully !!";
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.Body = "any text"
mailMessage.Priority = MailPriority.High;
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(mailMessage);


Anurag
@cheers@


这篇关于使用system.net.mail的smptp邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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