블로그

  • 2018 올해 목표

    공부하자

    자료 정리 ***********************

    중국어 – 어학원 찾기

    이직 – 어디가지??, 홍콩? 상해?

    취미 – 스킨스쿠버

     

  • 메일 이미지 첨부 보내기

    public void Sender()
    {
        MailMessage mail = new MailMessage();
        mail.To.Add("yoonhada@gmail.com");
        mail.Subject = "Test Mail";
        mail.Body = "This is for testing SMTP mail for GMAIL";
        //Attachment attachment = new Attachment("d:\\001.jpg");
        //mail.Attachments.Add(attachment);
    
        LinkedResource LinkedImage = new LinkedResource(@"d:\\001.jpg");
        LinkedImage.ContentId = "MyPic";
        AlternateView htmlView = AlternateView.CreateAlternateViewFromString("You should see image next to this line. <img src=cid:MyPic>", null, "text/html");
        htmlView.LinkedResources.Add(LinkedImage);
        mail.AlternateViews.Add(htmlView);
    
        SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
        smtpServer.Port = 587;
        smtpServer.Credentials = new System.Net.NetworkCredential("AAAAAAAAA@gmail.com", "AAAAAAAAAAAAA") as ICredentialsByHost;
        smtpServer.EnableSsl = true;
        ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            { return true; };
        smtpServer.Send(mail);
        Debug.Log("success");
    }