在asp.net中发送带有attachemt源代码的邮件# [英] send a mail with attachemt source code in asp.net #

查看:140
本文介绍了在asp.net中发送带有attachemt源代码的邮件#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net中发送带有attachemt源代码的邮件

解决方案

请看这里:在带有或不带附件的C#中发送电子邮件:通用例程。 [ ^ ]


Quote:



嗨..



MailMessage message = new MailMessage();

message.From = new MailAddress(xyz@gmail.com);

message.To.Add (另一个邮件);

message.Subject =你的主题;

message.Body =你的邮件正文;

message.IsBodyHtml = true;

if(IsAttachmentValid(FileUploadAttachment))

{

message.Attachments.Add(new Attachment(FileUploadAttachment.PostedFile.InputStream,FileUploadAttachment.FileName));

}



SmtpClient smtpClient =新的SmtpClient(smtp.gmail.com,25);

smtpClient.UseDefaultCredentials = false;

smtpClient .Credentials = new System.Net.NetworkCredential(xyz@gmail.com,);

smtpClient.EnableSsl = true;

smtpClient.Send(message) ;


send a mail with attachemt source code in asp.net

解决方案

See here: Sending an Email in C# with or without attachments: generic routine.[^]


Quote:


Hi..

MailMessage message = new MailMessage();
message.From = new MailAddress("xyz@gmail.com");
message.To.Add(anothermail);
message.Subject = "your subject";
message.Body = "your message body";
message.IsBodyHtml = true;
if (IsAttachmentValid(FileUploadAttachment))
{
message.Attachments.Add(new Attachment(FileUploadAttachment.PostedFile.InputStream, FileUploadAttachment.FileName));
}

SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 25);
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "");
smtpClient.EnableSsl = true;
smtpClient.Send(message);


这篇关于在asp.net中发送带有attachemt源代码的邮件#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆