通过C#在我的LAN接口发送电子邮件 [英] Send Email via C# through my LAN interface

查看:167
本文介绍了通过C#在我的LAN接口发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图模拟一些ad hoc网络,我用我的无线网卡连接到ad hoc网络,我希望能够邮寄自己的一些具体消息时我得到这个ad hoc网络的一些触发。通过LAN接口,我的笔记本电脑连接到互联网,并通过无线网卡连接到ad hoc网络。

I am trying to simulate some ad hoc network, I use my wireless card to connect to the ad hoc network, I want to be able to mail myself some specific messages when I get some trigger from this ad hoc network. my laptop connected to internet via Lan interface and connect to ad hoc network via wireless card.

这ID我的code:

 private void send_mail()
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.To.Add("XXXXX@YYYY.com");
            message.Subject = "test";
            message.From = new System.Net.Mail.MailAddress("ZZZZZ@MMMMM.com");
            message.Body = "This is the message body";
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("a.b.c.d");
            smtp.Send(message);
        }

我想知道如何设置界面发送邮件。 默认情况下,code想用我的无线网卡来发送邮件和无法连接到SMTP服务器,我得到了错误。
我想通过LAN接口不是无线接口我send_mail()函数连接。

I want to know How can I set interface for sending mail. by default the code want use my wireless card to send mail and can't connect to smtp server and I got error.
I want my send_mail() function connect through LAN interface not wireless interface.

推荐答案

设置你的LAN接口是默认网关,或设置你的LAN接口为您的默认连接/互联网连接。

Set your LAN interface to be your default gateway, or set your LAN interface to be your default connection/internet connection.

操作系统需要知道首先使用LAN接口互联网连接。

The operating system has to know to use the LAN interface first for internet connections.

这篇关于通过C#在我的LAN接口发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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