我用文本框和一个提交我的.aspx页面上的按钮,我想以电子邮件的按钮上点击所有这些文本框的数据,所以请告诉我的解决方案...如何从.aspx页面发送电子邮件?
-9
A
回答
3
按钮点击事件调用此函数
public bool SendOnlyToEmail(string sToMailAddr, string sSubject, string sMessage,
string sFromMailAddr)
{
try
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
if (string.IsNullOrEmpty(sFromMailAddr))
{
// fetching from address from web config key
msg.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["MailFrom"]);
}
else
{
msg.From = new System.Net.Mail.MailAddress(sFromMailAddr);
}
foreach (string address in sToMailAddr)
{
if (address.Length > 0)
{
msg.To.Add(address);
}
}
msg.Subject = sSubject;
msg.Body = sMessage;
msg.IsBodyHtml = true;
//fetching smtp address from web config key
System.Net.Mail.SmtpClient objSMTPClient = new System.Net.Mail.SmtpClient(System.Configuration.ConfigurationManager.AppSettings["MailServer"]);
//SmtpMail.SmtpServer = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["MailServer"]);
if (sToMailAddr.Length > 0)
{
objSMTPClient.Send(msg);
return true;
}
else
{
return false;
}
}
catch (Exception objException)
{
ErrorLog.InsertException(objException);
return false;
}
}
2
您可以使用SmtpClient
类。
2
有没有代码唯一的方法来解决这个问题;你依赖于有一个SMTP服务器来发送你的邮件。最佳案例场景:您已经在服务器上设置了一个默认端口。在这种情况下,你需要的是这样的:
SmtpClient client = new SmtpClient("localhost");
client.Send(new MailMessage("[email protected]", "[email protected]"));
如果做不到这一点,你可以看看建立一个免费的SMTP帐户,或(绝对必要无论如何,如果你在发出大量电子邮件规划),得到一个与Amazon SES等电子邮件服务提供商交涉。
1
您可以使用下面的代码来发送电子邮件:
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("senderEmail");
message.From = fromAddress;
message.Subject = "your subject";
message.Body = txtBox.Text;//Here put the textbox text
message.To.Add("to");
smtpClient.Send(message);//returns the boolean value ie. success:true
1
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//send the message
SmtpClient smtp = new SmtpClient();
smtp.Send(mail);
}
</script>
相关问题
- 1. 从aspx页面发送电子邮件
- 2. aspx:发送电子邮件
- 3. 从ASP.NET页面发送电子邮件
- 4. 创建一个单独的aspx页面发送电子邮件
- 5. asp.net发送aspx页面的部分电子邮件
- 6. 用gridviews发送aspx页面作为电子邮件
- 7. 如何从Wordpress页面发送电子邮件附件?
- 8. 页面发送电子邮件
- 9. 通过电子邮件发送页面
- 10. 如何从javascript发送电子邮件?
- 11. 如何从C发送电子邮件
- 12. 如何从Node.js发送电子邮件?
- 13. 如何从ASP.Net发送电子邮件
- 14. 如何从PHPmyAdmin发送电子邮件?
- 15. 如何从broadcastreceiver发送电子邮件?
- 16. 发送电子邮件从
- 17. 如何使用c#aspx发送电子邮件的MIME数据
- 18. 如何在发送电子邮件后防止页面刷新?
- 19. 如何通过HTML发送电子邮件页面
- 20. 如何在页面重定向之前发送电子邮件
- 21. 如何在访问页面时发送电子邮件通知?
- 22. 如何使用drupal_mail页面功能发送电子邮件 - front.tpl
- 23. 是否可以在电子邮件正文中发送aspx页面?
- 24. 从ASP经典页面发送电子邮件与凭据
- 25. 电子邮件从网站页面发送 - Odoo V9社区
- 26. 无法从PHP页面发送电子邮件
- 27. Ruby on Rails:从显示页面发送电子邮件
- 28. 不能通过电子邮件发送到Facebook页面从PHP
- 29. 从asp经典页面发送电子邮件
- 30. 发送电子邮件操作不发送电子邮件