如何在提交按钮中发送电子邮件 [英] how to snd email in submit button

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

问题描述

如何在提交按钮中发送电子邮件

解决方案

这是发送邮件的代码:

 使用 System.Net;
使用 System.Net.Mail;

 var  fromAddress =  MailAddress("  from@gmail.com" 来自名称");
 var  toAddress =  MailAddress("  to@example.com" 要命名" span>);
常量 字符串 fromPassword = "  fromPassword";
常量 字符串 subject = " 主题";
常量 字符串 body = " 正文";

 var  smtp =  SmtpClient
           {
               主持人= " ,
               端口=  587 ,
               EnableSsl =  true ,
               DeliveryMethod = SmtpDeliveryMethod.Network,
               UseDefaultCredentials =  false ,
               凭据=  NetworkCredential(fromAddress.Address,fromPassword)
           };
使用( var  message =  MailMessage( fromAddress,toAddress)
                     {
                         主题=主题,
                         身体=身体
                     })
{
    smtp.Send(消息);
} 



Dude,网上有很多示例,请尝试google.


您好兄弟,请使用这些链接.... .........

在ASP.Net 2.0中发送电子邮件-反馈表单 [ ^ ]

http://www.aspheute.com/english/20000918.asp [ http://csharpdotnetfreak.blogspot.com/2009/10/send- email-with-attachment-in-aspnet.html [ ^ ]


how to snd email in submit button

解决方案

This is code to send mail:

using System.Net;
using System.Net.Mail;

var fromAddress = new MailAddress("from@gmail.com", "From Name");
var toAddress = new MailAddress("to@example.com", "To Name");
const string fromPassword = "fromPassword";
const string subject = "Subject";
const string body = "Body";

var smtp = new SmtpClient
           {
               Host = "smtp.gmail.com",
               Port = 587,
               EnableSsl = true,
               DeliveryMethod = SmtpDeliveryMethod.Network,
               UseDefaultCredentials = false,
               Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
           };
using (var message = new MailMessage(fromAddress, toAddress)
                     {
                         Subject = subject,
                         Body = body
                     })
{
    smtp.Send(message);
}


Add it on button click.


Dude, there are loads of examples online, try google.


Hello dude use these links..............

Send Email in ASP.Net 2.0 - Feed back Form[^]

http://www.aspheute.com/english/20000918.asp[^]

http://csharpdotnetfreak.blogspot.com/2009/10/send-email-with-attachment-in-aspnet.html[^]


这篇关于如何在提交按钮中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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