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 Code is:
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>
<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>
Now my problem is that I have received only gmail accounts mails in my account but other accounts like hotmail,yahoo etc mails I have not recevied.How can receive all acounts mail in my accounts????
In order sent and receive mail's form different providers you have to change the smtp.Host
Property. For example,
SmtpServer.Host = "smtp.mail.yahoo.com";
SmtpServer.Host = "smtp.live.com";
To send from yahoo and live respectively...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.