چگونه در سی شارپ ایمیل ارسال کنیم؟ ارسال ایمیل با استفاده از smtp
برای ارسال ایمیل در سی شارپ از کد زیر استفاده کنید
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
namespace SendEmail
{
    public class SendGmail
    {
        public static void Send(string To,string Subject,string Body)
        {
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            mail.From = new MailAddress("rezakeshvari12345@gmail.com", "فارس لرن");
            mail.To.Add(To);
            mail.Subject = Subject;
            mail.Body = Body;
            mail.IsBodyHtml = true;
            //System.Net.Mail.Attachment attachment;
            // attachment = new System.Net.Mail.Attachment("c:/textfile.txt");
            // mail.Attachments.Add(attachment);
            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential("rezakeshvari12345@gmail.com", "@reza2686best");
            SmtpServer.EnableSsl = true;
            SmtpServer.Send(mail);
        }
    }
}
تمام.