相关疑难解决方法(0)

测试SMTP服务器正在通过C#运行

如何在不发送消息的情况下通过C#测试SMTP是否正常运行.

我当然可以尝试:

try{
// send email to "nonsense@example.com"
}
catch
{
// log "smtp is down"
}
Run Code Online (Sandbox Code Playgroud)

必须有一个更整洁的方法来做到这一点.

c# smtp

22
推荐指数
2
解决办法
3万
查看次数

在C#中以编程方式从app.config访问system.net设置

我试图以编程方式访问Windows应用程序app.config文件.特别是,我试图访问"system.net/mailSettings"以下代码

Configuration config = ConfigurationManager.OpenExeConfiguration(configFileName);

MailSettingsSectionGroup settings = 
    (MailSettingsSectionGroup)config.GetSectionGroup(@"system.net/mailSettings");

Console.WriteLine(settings.Smtp.DeliveryMethod.ToString());

Console.WriteLine("host: " + settings.Smtp.Network.Host + "");
Console.WriteLine("port: " + settings.Smtp.Network.Port + "");
Console.WriteLine("Username: " + settings.Smtp.Network.UserName + "");
Console.WriteLine("Password: " + settings.Smtp.Network.Password + "");
Console.WriteLine("from: " + settings.Smtp.From + "");
Run Code Online (Sandbox Code Playgroud)

未能给予主持人.它只获取端口号.其余的都是空的;

c# system.net

14
推荐指数
3
解决办法
2万
查看次数

如何在发送邮件之前验证smtp凭据?

我需要SmtpClient在发送邮件之前验证实例中设置的用户名和密码.使用此代码:

SmtpClient client = new SmtpClient(host);
client.Credentials = new NetworkCredential(username,password);
client.UseDefaultCredentials = false;

// Here I need to verify the credentials(i.e. username and password)
client.Send(mail);
Run Code Online (Sandbox Code Playgroud)

如何验证凭据标识的用户是否可以连接并发送邮件?

.net smtpclient

7
推荐指数
1
解决办法
2万
查看次数

如何从我的C#应用​​程序发送电子邮件?

这是我写的代码:

        MailMessage mail = new MailMessage("test@gmail.com", "me@myurl.com");

        mail.Subject = "This is a test!!";
        mail.Body = "testing...";

        SmtpPermission connectAccess = new SmtpPermission(SmtpAccess.Connect);
        System.Console.WriteLine("Access?  " + connectAccess.Access);

        SmtpClient client = new SmtpClient("mail.myurl.com", 2525);
        client.Send(mail);
Run Code Online (Sandbox Code Playgroud)

它不起作用.我在"client.Send(mail)"行显示"邮箱不可用.服务器响应是(MYLOCALCOMPUTERNAME)[我的本地IP]:3045目前不允许中继通过."

connectAccess.Access确实返回"连接"(我不确定这是否必要......我已将其添加进入以启动故障排除过程.)

这是否意味着我的本地机器必须以某种方式配置?当我将我的应用程序部署到其他人机器时呢?那里需要本地配置吗?我只是想从我的应用程序创建一个"发送反馈"类型的链接.

(注意:在我的实际应用程序中,我使用的是"to"和"from"中的真实电子邮件地址,而我的smtp实际上是我托管我的网址/网站的地方的smtp地址)

谢谢!

-Adeena

c# email smtpclient mailmessage

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×3

smtpclient ×2

.net ×1

email ×1

mailmessage ×1

smtp ×1

system.net ×1