Smtp电子邮件不是客户端传递失败。 [英] Smtp email not client delivery fail.
本文介绍了Smtp电子邮件不是客户端传递失败。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个简单的电子邮件客户端问题,代码工作正常。但是,邮件未发送到Gmail / Hotmail收件箱。我想知道是否需要将代码写入ASP.NET而不是WinForms项目。以下是以下代码,请提供建议。
Hi y'all,
I have an issue with a simple email client, the code works fine. However, the message is not delivered into Gmail/Hotmail inbox. I was wondering if I need to write the code into ASP.NET instead of WinForms project. Here's the code below, please advise.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
namespace Email_Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
try
{
SmtpClient client = new SmtpClient();
//client.Port = 25;
client.Port = 465;
// client.Host = "smtp.live.com";
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Timeout = 100000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("sener_email", "password");
MailMessage mm = new MailMessage("sender_email", "recipient_email ", "Subject", "Body");
mm.IsBodyHtml = true;
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.Send(mm);
label1.Text = "Message sent..";
}
catch (Exception e)
{
label1.Text = e.ToString();
}
}
}
}
谢谢,
我尝试过:
我试图在Gmail和Hotmail之间更改SMTP服务器,但结果相同。没有收到任何消息。
Thanks,
What I have tried:
I have tried to change the SMTP server between Gmail and Hotmail, but the results the same. No messages were received.
推荐答案
阅读: .net - 使用C#通过Gmail SMTP服务器发送电子邮件 - Stack Overflow [ ^ ]
这篇关于Smtp电子邮件不是客户端传递失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文