如何使用 log4net 从 Windows 窗体应用程序发送电子邮件
我已经在我的 C# 3.5 windows 窗体应用程序中设置了 log4net。我正在寻找如何使用 log4net 从客户端电脑发送电子邮件。 SMTPAppender 需要 SMTPHost 的知识,我见过的示例适用于 Web 应用程序。
有没有一种方法可以从可在任何客户端计算机上运行的应用程序发送电子邮件,无论该计算机是否位于域或网络中。我想我还需要能够检查是否有可用的连接。
我一直在寻找答案,但我没有太多使用电子邮件或网络进行编程的经验,不知道要寻找什么。有什么想法可以引导我走向正确的方向吗?
I have set up log4net in my C# 3.5 windows form application. I am looking for how to send email from a client pc with log4net. The SMTPAppender requires knowledge of SMTPHost and the examples I've seen are for web applications.
Is there a way to send email from an application that will work on any client's computer that may or may not be in a domain or network. I guess I would also need to be able to check if there is a connection available.
I've searched for an answer but I don't have much experience programming with email or the web to know what to look for. Any ideas to steer me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
c# SmtpClient 非常适合您的需求。这是一些示例代码(主机是IP地址或主机名,端口通常是25,但不一定):
c# SmtpClient is quite right for your needs. here's some sample code (host is an ip address or host name, and the port is usually 25, but not necessarily) :