.NET을 활용하여 gmail을 통해 개인화 된 이메일을 보내기 위해 .NET을 활용합니다
네임 스페이스는 필요한 도구를 제공합니다. 코드 예는 다음과 같습니다.
중요한 메모 :
2 요인 인증 (2FA) : Gmail 계정에 2FA가 활성화 된 경우 Google 보안 설정을 통해 앱 특정 비밀번호를 생성하고 대신 사용해야합니다. 일반 비밀번호의.
Gmail 설정에서 "덜 안전한 앱 액세스"를 활성화하지 마십시오. 2FA 및 앱 특정 암호 사용 권장 및보다 안전한 접근 방식입니다. System.Net.Mail
<code class="language-csharp">using System.Net; using System.Net.Mail; // Sender and recipient email addresses var fromAddress = new MailAddress("example@gmail.com"); var toAddress = new MailAddress("receiver@example.com"); // Gmail authentication credentials (use App Password if 2-Step Verification is enabled) const string fromPassword = "{Your Gmail password or app-specific password}"; // Email content const string subject = "Personalized Email"; const string body = "Your customized message to the band"; // Gmail SMTP server settings var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; // Compose and send the email using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); }</code>
및 변수를 동적으로 채워야합니다.
위 내용은 .NET을 사용하여 Gmail 계정에서 개인화 된 이메일을 어떻게 보내려면?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!