아래 코드는 SMTP 이메일 송신 샘플입니다.
public void MailSend() { string HostAddr = "smtp호스트주소"; int Port = 587; //smtp 서버 포트 string MailId = "사용자 메일 아이디"; string MailPw = "사용자 메일 암호"; SmtpClient SmtpServer = new SmtpClient(HostAddr, Port); SmtpServer.UseDefaultCredentials = true; //사용자 기본인증 SmtpServer.EnableSsl = true; //SSL 설정 SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network; //메일 송신 방식 SmtpServer.Credentials = new System.Net.NetworkCredential(MailId, MailPw); //메일 아이디 및 암호 MailMessage mail = new MailMessage(); System.Net.Mail.Attachment attachment = new Attachment("첨부파일경로"); mail.From = new MailAddress("송신메일주소", "이름", System.Text.Encoding.UTF8); mail.To.Add("수신메일주소1,수신메일주소2"); mail.Subject = "메일제목"; mail.Attachments.Add(attachment); //첨부파일 mail.Body = "메일내용"; mail.BodyEncoding = System.Text.Encoding.UTF8;//한글이 안깨지기 위해서 사용 mail.SubjectEncoding = System.Text.Encoding.UTF8;//한글이 안깨지기 위해서 사용 SmtpServer.Send(mail); // 메일 발송 mail.Dispose(); }