클리엘
CLIEL LAB
클리엘
전체 방문자
오늘
어제
  • 분류 전체보기 (514)
    • Mobile (47)
      • Kotlin (47)
    • Web (84)
      • NestJS (9)
      • HTML5 & CSS3 (38)
      • Javascript (20)
      • TypeScript (6)
      • JQuery (11)
    • .NET (301)
      • C# (84)
      • ASP.NET (67)
      • Windows API for .NET (128)
    • Server (53)
      • SQL Server (10)
      • MariaDB (18)
      • Windows Server (6)
      • node.js (19)
    • System (12)
      • 작업LOG (12)
    • Review (11)
    • ETC (6)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • 블로그 정리

인기 글

태그

  • Entity Framework
  • ASP.NET
  • NestJS
  • c#
  • asp.net core web api
  • asp.net core
  • exception
  • node.js
  • .NET
  • Kotlin
  • 변수
  • MariaDB
  • LINQ
  • HTML5
  • CSS3
  • android
  • jQuery
  • JavaScript
  • android studio
  • Windows API

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
클리엘

CLIEL LAB

.NET/ASP.NET

[ASP.NET Core] MailKit 사용

2021. 5. 28. 16:02
728x90

'MailKit'이라는 이름으로 프로젝트에 NuGet package를 추가합니다.

 

//발신자 설정
MailboxAddress from = new MailboxAddress("이름(생략가능)", "메일주소");
message.From.Add(from);

//수신자 설정
MailboxAddress to = new MailboxAddress("이름(생략가능)", "메일주소");
message.To.Add(to);

//메일제목
message.Subject = "안뇽~";

//메일본문
BodyBuilder bodyBuilder = new BodyBuilder();
bodyBuilder.HtmlBody = "<h1>반가워~</h1>";

//필요한 경우 첨부파일
//bodyBuilder.Attachments.Add("C:\\file.jpg");
message.Body = bodyBuilder.ToMessageBody();

//SMTP 서버연결
//보안연결은 서버의 설정에 따라 다음
SmtpClient client = new SmtpClient();
client.Connect("메일서버주소", "포트번호", MailKit.Security.SecureSocketOptions.None);
client.Authenticate("SMTP 연결계정 메일주소", "SMTP 연결계정 비밀번호");

//발송
client.Send(message);
client.Disconnect(true);
client.Dispose();
728x90
저작자표시 비영리 변경금지 (새창열림)

'.NET > ASP.NET' 카테고리의 다른 글

[ASP.NET Core Web API] Swagger에 JWT인증 적용하기  (0) 2021.06.15
[ASP.NET Core] ASP.NET Core API에 ReactJS 배포하기  (0) 2021.06.01
[ASP.NET Core Web API] 'IAsyncEnumerable Reader' reached the configured maximum size of the buffer when enumerating a value of type  (0) 2021.03.30
[ASP.NET Core] IIS 호스팅  (0) 2021.03.30
[ASP.NET Core Web API] Action Method - 응답  (0) 2021.03.26
    '.NET/ASP.NET' 카테고리의 다른 글
    • [ASP.NET Core Web API] Swagger에 JWT인증 적용하기
    • [ASP.NET Core] ASP.NET Core API에 ReactJS 배포하기
    • [ASP.NET Core Web API] 'IAsyncEnumerable Reader' reached the configured maximum size of the buffer when enumerating a value of type
    • [ASP.NET Core] IIS 호스팅
    클리엘
    클리엘
    누구냐 넌?

    티스토리툴바