tencent cloud

Simple Email Service

제품 소개
제품 개요
제품 기능
제품 장점
사용 사례
사양
구매 가이드
요금 안내
시작하기
이메일 설정
이메일 발송
신뢰도 등급
콘솔 가이드
이메일 설정
이메일 전송
데이터 통계
SMTP 문서
SMTP 이메일 전송 가이드
SMTP 서비스 주소
Java 호출 예시
Go 호출 예시
PHP 호출 예시
첨부파일이 있는 이메일 전송
오류 코드
Webhook 문서
이메일 이벤트 알림
전송 제한
첨부파일 유형
FAQ
시작하기
과금
전송 제한
전송 기능
도메인
템플릿
신원 확인 및 설정
전용 IP
전송
API 사용
콜백
스팸함
보안성
주의 사항
기타 질문
고객센터
문서Simple Email Service

Sample Call for C#

포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-12-23 14:41:46
Due to the official library's inadequate support for ports 465 and 587, it is recommended to use MailKit, as shown in the following example.
using System;
using MimeKit;
using MailKit.Net.Smtp;
using MailKit.Security;

// This code example uses MailKit (MIT License: https://github.com/jstedfast/MailKit)

class Program
{
static void Main()
{
try
{
// Sender address created in the console
string fromEmail = "test@example.com";
// SMTP password set in the console
string password = "your password";
string toEmail = "to@example.com";
string smtpHost = "sg-smtp.qcloudmail.com";
int smtpPort = 465;
var message = new MimeMessage();
message.From.Add(new MailboxAddress("", fromEmail));
message.To.Add(new MailboxAddress("", toEmail));
message.Subject = "Test Email with HTML Content";
message.Body = new TextPart("html")
{
Text = @"
<html>
<body>
<h1 style='color:blue;'>Hello!</h1>
<p>This is a <b>HTML test email</b> from <i>Tencent Cloud SES</i>.</p>
<p>Visit <a href='https://www.tencentcloud.com/'>this link</a> for more info.</p>
</body>
</html>"
};

using (var client = new SmtpClient())
{
client.Connect(smtpHost, smtpPort, SecureSocketOptions.SslOnConnect);
client.Authenticate(fromEmail, password);
client.Send(message);
client.Disconnect(true);
}

Console.WriteLine("Email sent successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백