asp.net 邮件发送

asp.net mvc 发送邮件功能 asp.net mvc 发送邮件功能,配置里面主要配置发送人邮件的的信息,注意:邮箱必须要开通smtp服务,否则是无法使用该功能的 阅读详情
用System.Web.Mail发送邮件,适用于.net1.1,.net2.0请用System.Net.Mail

先引用System.Web
1,发送简单邮件
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body"
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

这里的smtpserver只能是那些不需要验证的smtp服务器,像126,sina,yahoo等等的邮箱,都需要验证,所以不能用。用这些邮箱发信后面会讲到


2,发送Html邮件
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.BodyFormat = MailFormat.Html;
mail.Body = "this is my test email body.<br><b>this part is in bold</b>";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );


[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.BodyFormat = MailFormat.Html
mail.Body = "this is my test email body.<br><b>this part is in bold</b>"
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

3,发送附件
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) ); //create the attachment
mail.Attachments.Add( attachment ); //add the attachment
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body."
Dim attachment As New MailAttachment(Server.MapPath("test.txt")) 'create the attachment
mail.Attachments.Add(attachment) 'add the attachment
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

4,修改发件人和收件人的名称
比如发件人的地址是abc@126.com,我们用outlook收到信,From一栏里将直接显示abc@126.com.
能不能在From一栏里显示友好一点的名字呢?
比如显示Tony Gong

方法如下:
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "/"John/" <me@mycompany.com>";
mail.From = "/"Tony Gong/" <you@yourcompany.com>";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );


[ VB.NET ]
Dim mail As New MailMessage()
mail.To = """John"" <me@mycompany.com>"
mail.From = """Tony Gong"" <you@yourcompany.com>"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body."
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

5,发送给多人
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body."
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

6,用需要Smtp验证的邮箱发信
现在为了防止垃圾邮件,绝大部分Smtp服务器需要验证了
发信方法如下:
[ C# ]
 MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "abc@126.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "abc"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "your password"); //set your password here

SmtpMail.SmtpServer = "smtp.126.com"; //your real server goes here
SmtpMail.Send( mail );




[ VB.NET ]

Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "abc@126.com"
mail.Subject = "this is a test email."
mail.Body = "Some text goes here"
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "abc") 'set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Your Password") 'set your password here
SmtpMail.SmtpServer = "smtp.126.com" 'your real server goes here
SmtpMail.Send(mail)



7,修改smtp服务器的端口,以及使用SSL加密
大部分smtp服务器的端口是25,但有些却不是
同时,绝大部分Smtp服务器不需要SSL登陆,有些却需要
比如Gmail,smtp端口是:465,同时支持SSL
代码如下:

[ C# ]

MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "abc@126.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "abc"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "your password"); //set your password here

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",465);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
SmtpMail.SmtpServer = "smtp.126.com"; //your real server goes here
SmtpMail.Send( mail );








[ VB.NET ]


Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "abc@126.com"
mail.Subject = "this is a test email."
mail.Body = "Some text goes here"
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "abc") 'set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Your Password") 'set your password here

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",465)
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true")

SmtpMail.SmtpServer = "smtp.126.com" 'your real server goes here
SmtpMail.Send(mail)
ASP.NET中实现邮件发送的完整指南 SMTP(Simple Mail Transfer Protocol)是一种用于发送电子邮件的网络通信协议。它规定了邮件服务器之间以及邮件客户端和服务器之间的消息传输规则。SMTP协议工作在TCP/IP协议的第七层(应用层),默认使用25端口进行通信。理解SMTP协议的运作机制对于正确配置邮件系统至关重要。 阅读详情

相关推荐

Asp.net邮件发送

NULL 博文链接:https://jhxk.iteye.com/blog/396528

.net发送邮件的一些技巧

用System.Web.Mail发送邮件,适用于.net1.1,.net2.0请用System.Net.Mail先引用System.Web1,发送简单邮件[ C# ] MailMessage mail = new MailMessage();mail.To = "me@mycompany.com";mail.From = "you@yourcompany.com";mail.Subject =

Wally_Lee的专栏 2311

asp.net 发邮件

asp.net 发邮件,他使 asp.net也能发邮件

在Asp.Net中使用SmtpMail发送邮件的方法

在ASP中,就可以通过调用CDONTS组件发送简单邮件,在ASP.Net中,自然也可以。不同的是,.Net Framework中,将这一组件封装到了System.Web.Mail命名空间中。一个典型的邮件发送程序如下:MailMessage mail=new MailMessage(); mail.From="service@brookes.com"; mail.To="brookes@bro

Brookes的专栏 2488

Asp.net邮件系统(在线收发)源码

Asp.net邮件系统(在线收发)源码! 值得下载看看!资源免费,大家分享!! 更多免费资源 http://ynsky.download.csdn.net/

ASP.NET发送邮件

ASP.NET免费发送邮件代码

asp.net 发送邮件代码

  asp.net 发送邮件代码 说到发送邮件发送,先提一下SMTP(呵呵,高手就跳过这一段吧!)。 SMTP的全称是“Simple Mail Transfer Protocol”,即简单邮件传输协议。它是一组用于从源地址到目的地址传输邮件的规范,通过它来控制邮件的中转方式。SMTP 协议属于 TCP/IP 协议簇,它帮助每台计算机在发送或中转信件时找到下一个目的地。SMTP 服务器就是遵循

老虎的专栏 2万+

asp.net发送邮件

asp.net发送邮件源码 发送人的邮箱地址,邮箱密码,SMTP服务器设置正确即可发送邮件。

asp.net发送电子邮件_如何在ASP.NET Core中发送电子邮件

asp.net发送电子邮件 您通常需要通过应用程序发送电子邮件。 您可以利用MailKit NuGet包在ASP.NET Core中发送电子邮件。 MailKit是一个开源邮件客户端库,可以在Windows,Linux或Mac系统上运行的.NET或.NET Core应用程序中使用。 本文讨论了如何使用MailKit NuGet包在ASP.NET Core中发送电子邮件。 若要使用本文提供的代...

cxu0262的博客 1444

asp.net(C#)发送电子邮件

示例demo,含发送邮件的相关类源代码,分享一下。

ASP.NET 的邮件

可以的资源 欢迎下载,与人分享是最快乐的啊

[ASP.NET]asp.net发送邮件(超详细)

asp.net发送邮件 文章目录asp.net发送邮件1.设置qq邮箱smtp服务2.发送邮件代码3设置web.config 1.设置qq邮箱smtp服务 2.发送邮件代码 using System; using System.Configuration; using System.Net; using System.Net.Mail; public class EmailSender { //从Web.config中的<appSettings>配置节获取相应的键值 priv

qq_43587354的博客 1万+

asp.net邮件发送

asp.net邮件发送 需要在本地设置好stmp 在iis里面设置

ASP.NET 发送邮件带附件

Default2.aspx页面上的代码 电子邮件发送测试程序

6741

MaaS 商业模式全面分析报告:从技术赋能到商业变现的全链条探索

MaaS(模型即服务)商业模式正成为AI产业主流,2024年上半年中国市场规模达2.5亿元,预计2027年占比将提升至47%。该模式通过云服务提供预训练AI模型,大幅降低企业应用AI的技术门槛和成本。核心盈利方式包括按使用量计费、订阅制、定制化服务等,其中混合模式因灵活性成为趋势。MaaS产业链包含模型提供商、云平台、应用开发商和最终用户,重塑了AI产业格局。随着《数据法案》等监管加强,数据增值服务面临更严格合规要求。未来五年,中国MaaS市场增速预计超50%,用户规模将从2025年2.1亿增至2030年5

芯片行业20年 · 参与定义实现千万级量产出货 · AI芯片PM 2892

【汽车主动降噪】【ANC算法优化】基于深度学习的汽车主动噪声控制技术研究及Matlab实现

本文探讨了基于深度学习的汽车主动降噪(ANC)算法优化方案。针对传统FXLMS算法在应对复杂、非线性车内噪声时的局限性,文章详细解析了如何利用神经网络作为非线性建模器、深度滤波器或智能步长调节器来增强ANC系统性能,并提供了完整的Matlab仿真实战流程,展示了深度学习在提升降噪效果和收敛速度方面的潜力。

seed的博客 540

ASP.NET发送电子邮件

http://www.cnblogs.com/ForEvErNoME/archive/2012/06/05/2529259.html 1.补充知识 (1)POP3和SMTP服务器是什么? 简单点来说:POP3 用于接收电子邮件 ,SMTP 用于发送电子邮件。 (1)POP3具体指什么? POP3(Post Office Protocol 3)即邮局协议的第3个版本,它是规定个人计

珍惜所有的一切 6982

STM32CubeMX Nucleo F767ZI 教程(1)

系列文章目录 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 例如:第一章 Python 机器学习入门之pandas的使用 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录系列文章目录前言一、pandas是什么?二、使用步骤1.引入库2.读入数据总结 前言 官网上买了个NUCLEO F767ZI 的开发板,144引脚的芯片,https://www.st.com/content/st_com/zh/products/evaluation-tools/prod

fafuwxm 2029

asp.net三种发送邮件代码(stmp,无组件邮件发送)

asp教程.net三种发送邮件代码(stmp,无组件邮件发送) public bool sendmails() { smtpclient _smtpclient = new smtpclient(); _smtpclient.deliverymethod = smtpdeliverymethod.network;//指定电子邮件发送方式 _smtpclient.host = "i

qq_35306193的博客 3037

SAP SD核心流程解析:从销售订单到财务结算的实战指南

本文深入解析SAP SD模块从销售订单到财务结算的核心流程,重点剖析了销售订单中的行项目类别如何作为流程的“总开关”,决定了后续交货、开票及财务集成的走向。文章结合实战案例,详细拆解了正常销售、退货、第三方销售、寄售等典型流程的配置要点与国内化适配方案,并阐述了SD与财务模块集成的关键连接点,为顾问和用户提供了一份全面的实战指南。

weixin_29250403的博客 427

OPTI Toolbox v2.28 安装与 3 个求解器补全:SCIP、SeDuMi、MOSEK 配置详解

本文详细介绍了OPTI Toolbox v2.28在MATLAB环境下的完整安装指南,包括SCIP、SeDuMi和MOSEK三个关键求解器的配置与优化技巧。通过分步指导和实战案例,帮助用户高效搭建强大的优化工具包,提升混合整数规划、二次约束二次规划等复杂问题的求解效率。

weixin_29039773的博客 350

asp.net 使用html模板发送电子邮件

在做一个基于ASP.NET的项目时需要使用html模板发送电子邮件,研究了下,总结如下: HTML模板 HTML Template Dear $USER_NAME$, My name is $NAME$ Best Regards, $MY_NAME$ 其中用$符号包裹的字符串是要在程序里动态替换的。 发送邮件 ///

Johnson的专栏 6763

Python爬取马蜂窝旅游攻略详细实战指南

马蜂窝是国内非常知名的旅游攻略网站,包含了大量的景点介绍、旅行攻略、游记等信息。爬取马蜂窝的数据对于旅游数据分析、旅游产品推荐等有重要价值。但由于马蜂窝对爬虫有一定的反爬措施,并且页面中大量内容通过JavaScript动态加载,爬虫难度相对较大。本篇博客将带你从零开始,使用Python和相关爬虫技术,逐步实现对马蜂窝旅游攻略内容的高效爬取。并结合实战经验,分析反爬策略,提供科学合理的绕过方案。本文介绍了马蜂窝攻略的结构和抓取难点。演示了静态+动态内容的混合爬取技术。介绍了多线程和异步加速方法。

2201_76125261的博客 588

asp.net 发送邮件

protected void Button1_Click(object sender, EventArgs e) { SendSMTPEMail("smtp.qq.com", "861816288@qq.com", "XX密码XXXX", "450940118@qq.com", "123", "用asp.net发送邮件,用qq的smtp.qq.com服务器,

quryktcs的博客 799

(一)激光线扫描-三维成像原理

激光线扫描是一种使用激光作为光源,通过特定的扫描设备(如光学镜头、电机驱动的镜头或电子扫描设备)将激光束引导到目标表面,并按照预定的路径进行扫描的技术。这种技术通常用于测量、检测、打印、切割等多种应用中。

FlyWine的博客 3629

第28节:cesium 加载高程数据(含源码+视频)

cesium 加载高程(地形)数据

qq_29384639的博客 1741
上一篇: ASP.NET长文章分页显示函数
netnpc
博客等级 码龄19年 31粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值