Unity3D教程:如何利用U3D发送邮件附件
发表于2016-09-28
案例效果图
代码
1234567891011121314151617181920212223242526 class
Program
{
static
void
Main(
string
[] args)
{
SmtpClient mailClient =
new
SmtpClient(
"smtp.qq.com"
);
mailClient.EnableSsl =
true
;
//Credentials登陆SMTP服务器的身份验证.
mailClient.Credentials =
new
NetworkCredential(
"1213250243@qq.com"
,
"密码"
);
//test@qq.com发件人地址、test@tom.com收件人地址
MailMessage message =
new
MailMessage(
new
MailAddress(
"1213250243@qq.com"
),
new
MailAddress(
"aladdingame@qq.com"
));
// message.Bcc.Add(new MailAddress("tst@qq.com")); //可以添加多个收件人
message.Body =
"Hello Word!"
;
//邮件内容
message.Subject =
"this is a test"
;
//邮件主题
//Attachment 附件
Attachment att =
new
Attachment(
@"D:/test.mp3"
);
message.Attachments.Add(att);
//添加附件
Console.WriteLine(
"Start Send Mail...."
);
//发送....
mailClient.Send(message);
Console.WriteLine(
"Send Mail Successed"
);
Console.ReadLine();
}
}
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 | class Program { static void Main( string [] args) { SmtpClient mailClient = new SmtpClient( "smtp.qq.com" ); mailClient.EnableSsl = true ; //Credentials登陆SMTP服务器的身份验证. mailClient.Credentials = new NetworkCredential( "1213250243@qq.com" , "密码" ); //test@qq.com发件人地址、test@tom.com收件人地址 MailMessage message = new MailMessage( new MailAddress( "1213250243@qq.com" ), new MailAddress( "aladdingame@qq.com" )); // message.Bcc.Add(new MailAddress("tst@qq.com")); //可以添加多个收件人 message.Body = "Hello Word!" ; //邮件内容 message.Subject = "this is a test" ; //邮件主题 //Attachment 附件 Attachment att = new Attachment( @"D:/test.mp3" ); message.Attachments.Add(att); //添加附件 Console.WriteLine( "Start Send Mail...." ); //发送.... mailClient.Send(message); Console.WriteLine( "Send Mail Successed" ); Console.ReadLine(); } } |
Unity |
| 项目源码 |