2016. 2. 22. 05:40

간단하게 할수 있습니다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
 
public class mono_gmail : MonoBehaviour
{
        void Main ()
        {
            MailMessage mail = new MailMessage();
             
            mail.From = new MailAddress("youraddress@gmail.com");
            mail.To.Add("youraddress@gmail.com");
            mail.Subject = "Test Mail";
            mail.Body = "This is for testing SMTP mail from GMAIL";
            SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");      
            smtpServer.Port = 587;
            smtpServer.Credentials = new System.Net.NetworkCredential("youraddress@gmail.com""yourpassword"as ICredentialsByHost;
            smtpServer.EnableSsl = true;
            ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
            {
             return true
            };
            smtpServer.Send(mail); 
            Debug.Log("success");   
       }
}
 
 
cs



또한 파일을 첨부해서 보낸다면


1
2
3
4
5
 
                System.Net.Mail.Attachment attachment;  
                attachment = new System.Net.Mail.Attachment("D:\\temp\\file.txt");  
                  
                mail.Attachments.Add(attachment);
cs

위와

위와같은 코드를 추가하면 됩니다.


Posted by 시리시안