如何使用asp.net发送电子邮件 [英] How to send Email using asp.net

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

问题描述



我想发送电子邮件,我想知道如何获取系统的Smtp,以及如何通过正文发送邮件,如下所示

名称从到天数状态

谢谢
Abinav Shankar

Hi

I want to send Email I want to know how to get the Smtp of my system and how to send mail with the body as follows

Name from To Number of Days Status

Thanks
Abinav Shankar

推荐答案

对于SMTP地址,您将必须查看您的电子邮件主机-该地址不是固定的,并且根据系统的意愿而有所不同.设置系统的人.

找到它后,这里将提供一个通用例程,该例程将帮助您:
For SMTP address, you will have to look at your Email host - the address is not fixed, and varies from system to system according to the wishes of the person who set up the system.

Once you have found it, there is a generic routine here which will help: Sending an Email in C# with or without attachments: generic routine.[^]


MailMessage oMsg = new MailMessage();
                oMsg.From = new MailAddress("xxx@gmail.com", "xxx");
                oMsg.To.Add(new MailAddress("yyy@gmail.com", "xxx"));
                oMsg.Subject = "Packet Parsing Problem";
                oMsg.Body = " Problem Occuread test mail";
                oMsg.SubjectEncoding = System.Text.Encoding.UTF8;
                oMsg.BodyEncoding = System.Text.Encoding.UTF8;
                oMsg.IsBodyHtml = false;
                oMsg.Priority = MailPriority.High;
 
                SmtpClient oSmtp = new SmtpClient("smtp.gmail.com", 587);
                oSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                oSmtp.EnableSsl = true;
 
                NetworkCredential oCredential = new NetworkCredential("xxx@gmail.com", "123456aA");
                oSmtp.UseDefaultCredentials = false;
                oSmtp.Credentials = oCredential;
                oSmtp.Send(oMsg);



试试这个,它将起作用



Try this , Its will work


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

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