السلام عليكم ورحمة الله وبركاته
صباح الخير للجميع
انا عندي مشكلة واتمنى المساعدة اذا سمحتوا انا حاب ارسل ايميل عن طريق الهوتميل من خلال ASP حصلت كود وطبقته والكود ماشي ولكن لما ارفعه على السيرفر يعطيني مشاكل !! ما ادري بالضبط وش المشكلة ؟ المشكلة مثل ما هو واضح ادناه:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The remote name could not be resolved: 'smtp.live.com'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote name could not be resolved: 'smtp.live.com'
Source Error:
Line 43: smtpClient.UseDefaultCredentials = true;
Line 44: smtpClient.Credentials = new System.Net.NetworkCredential("gccpo@hotmail.com", "administrator");
Line 45: smtpClient.Send(message);
Line 46: msg = "Successful";وهذا الكود اللي اطبقه على جهازي ويمشي وضعه
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
public partial class Forms_SendingEmail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//Calling the function SendMail
Response.Write(SendMail("***@hotmail.com","xxx@hotmail.com","***@yahoo.com","Test Mail","Test Mail Body"));
}
public string SendMail(string toList, string from, string ccList, string subject, string body)
{
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(from);
message.From = fromAddress;
message.To.Add(toList);
if (ccList != null && ccList != string.Empty)
message.CC.Add(ccList);
message.Subject = subject;
message.IsBodyHtml = true;
message.Body = body;
smtpClient.Host = "smtp.live.com";
smtpClient.Port = 25;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("xxx@hotmail.com", "*******");
smtpClient.Send(message);
msg = "Successful";
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
}