问题描述
大家好,
我是ASP.NET的新手,现在开始学习MVC,以提高我在.NET平台上的技能。目前,我正在练习自己做不同的任务和我非常了解MVC,并且非常想知道如何使用MVC5向客户邮箱发送电子邮件。任何人都可以共享任何链接或博客;从哪里我可以学习和实施它。我读了两三篇文章,但是我不明白代码如何使用web帮助程序类来实现它。
我尝试了什么:
请与我分享链接,以便我可以实施;我非常感谢。
Hi all,
I am newbie to ASP.NET and now start learning MVC , to enhance my skills on .NET platform . Currently , i am practicing myself to do different task & pretty much know about MVC and eager to know how we can send email to client mailbox by using MVC5 . Can anyone share any link or blog ; from where i can learn and implement it . I read two or three articles but I don't understand the code properly how to use web helper class to implement it.
What I have tried:
Kindly share me the link , so that i can implement it ; i am highly appreciate for the same.
推荐答案
string to = "jane@contoso.com";
string from = "ben@contoso.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = @"Using this new feature, you can send an e-mail message from an application very easily.";
SmtpClient client = new SmtpClient(server);
// Credentials are necessary if the server requires the client
// to authenticate before it will send e-mail on the client's behalf.
client.UseDefaultCredentials = true;
try {
client.Send(message);
}
catch (Exception ex) {
Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",
ex.ToString() );
}
这篇关于如何在MVC中向客户端发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!