مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

منال مجموعه

عضویت از 1393/10/21

ارسال ایمیل در ASP,NET

  • دوشنبه 14 مهر 1399
  • 18:50
تشکر میکنم

با سلام

کد زیر رو اجرا کردم رو سرور .

 using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;

public partial class SendEmail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }




    protected void button1_Click(object sender, EventArgs e)
    {


        try
        {
            SmtpClient client = new SmtpClient();
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl = true;
            //client.Host = "mail.scu.ac.ir";
            client.Host = "192.168.168.20";
            client.Port = 465;
            client.Credentials = new System.Net.NetworkCredential("rms@scu.ac.ir", "****");
           
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl = true;
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 
            MailMessage mail = new MailMessage();

            //Setting From , To and CC
            mail.From = new MailAddress("***@scu.ac.ir", "RMS");
            mail.To.Add(new MailAddress("***@scu.ac.ir"));
          

            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
           

            client.Send(mail);

            Response.Write("<script>alert('mail Send');</script>");
            Label4.Text = "mail Send";
        }

        catch (Exception ex)
        {
            //Response.Write("<script>alert(ex.ToString());</script>");
            Label4.Text = (ex.ToString());

        }


    }
}
با خطا مواجه شده .
 با مسیولین شبکه چک کردم گفتن باید به ازای تمام CERTIFICATION ها شما  TRUE 
 برگردونین من هم کد زیر رو اضافه کردم:
  ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
اما هنوز خطا زیر رو میده

System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message)

 

پاسخ های این پرسش

تعداد پاسخ ها : 0 پاسخ
در حال حاضر هیچ پاسخی ارسال نشده است
کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)