我通过gmail帐户收到电子邮件,但没有收到其他帐户,如雅虎,hotmail等在asp.net c#

本文关键字:hotmail 雅虎 等在 其他 net asp gmail 电子邮件 | 更新日期: 2023-09-27 18:03:40

My Code Is:

using System.Net.Mail;<br/>
using System.Net;<br/>
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void home_btn_Click(object sender, ImageClickEventArgs e)
{
     MailMessage msg = new MailMessage();
     msg.From = new MailAddress(home_mail.Text);
     msg.To.Add(new MailAddress("ashwanirawat22@gmail.com"));
    //msg.CC.Add ( new MailAddress(txtcc.Text));
    //msg.Subject = txtSubject.Text;
    msg.Body = home_msg.Text;
    msg.IsBodyHtml = false;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";
    smtp.Credentials = new System.Net.NetworkCredential(home_mail.Text,home_pass.Text);
    label1.Visible = true;
    smtp.EnableSsl = true;
    try
    {
        smtp.Send(msg);
        label1.Text = "Email Send";
    }
    catch
    {
        label1.Text = "Email Failed";
    }
    home_msg.Text = "";
    home_mail.Text = "";
    home_pass.Text = "";
     }
}

Html代码为:

Message: <asp:TextBox ID="home_msg" Rows="5" Columns="45" TextMode="MultiLine"runat="server">
</asp:TextBox><br/>
From: <asp:TextBox ID="home_mail"  runat="server" Height="30px" Width="380px"></asp:TextBox></div><br />
Password:
<asp:TextBox ID="home_pass"  runat="server" Height="30px" Width="380px" TextMode="Password"></asp:TextBox>
&nbsp; <asp:ImageButton ID="home_btn" ImageUrl="~/images/button.png" runat="server" 
Height="30px" Width="75px" onclick="home_btn_Click" />
<asp:Label ID="label1" runat="server"></asp:Label>

现在我的问题是,我只收到gmail帐户的邮件在我的帐户,但其他帐户如hotmail,雅虎等邮件我没有收到。怎样才能在我的账户????中收到所有账户的邮件

我通过gmail帐户收到电子邮件,但没有收到其他帐户,如雅虎,hotmail等在asp.net c#

为了发送和接收来自不同提供商的邮件,您必须更改smtp.Host属性。例如,

SmtpServer.Host = "smtp.mail.yahoo.com";
SmtpServer.Host = "smtp.live.com";

分别从yahoo和live发送