数据库如何加载和显示图像.in asp.net .. [英] How database to load and display images .in asp.net..
本文介绍了数据库如何加载和显示图像.in asp.net ..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将图像保存到数据库,并且图像可以加载到用户创建的文件夹,然后我们必须选择图像并发送到邮件。
我使用以下代码,< br $> b $ b
受保护 void Upload_Click( object sender,EventArgs e)
{
String s =( String )会话[ temp];
if (FileUpload1.HasFile)
{
// < span class =code-comment> string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
// FileUpload1.PostedFile.SaveAs(Server.MapPath(〜/+ s +\\)+ fileName);
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
path = Server.MapPath( 〜/ + s + \\)+ fileName;
FileUpload1.SaveAs(path);
Response.Redirect(Request.Url.AbsoluteUri); insert imges
// Session [PATH] = path;
}
受保护 void Send_Click( object sender,EventArgs e)
{
String sndps =( String )会话[ pswd跨度>];
// String s =(String)Session [PATH];
字符串 s =(字符串)会话[ temp];
字符串 em =(字符串)会话[ email];
// TextBox1.Text = em;
MailMessage msg = new MailMessage();
string ActivationUrl = string .Empty;
string emailid = string .Empty;
SmtpClient smtp = new SmtpClient();
string emailId = em;
msg.From = new MailAddress( a@gmail.com跨度>);
msg.To.Add(em);
msg.Subject = Conformation mail;
msg.Body = 您的登录密码为: + sndps;
msg.IsBodyHtml = true ;
// string [] files = Directory.GetFiles(path);
/ * foreach(文件中的字符串文件)
{
Console.WriteLine(file);
} * /
// msg.Attachments.Add (文件);
// 新附件(文件));
/// / if(FileUpload1.HasFile)
/// / {
// msg.Attachments.Add(new Attachment(files。));
/// /}
smtp.Host = smtp.gmail.com跨度>;
smtp.EnableSsl = true ;
NetworkCredential NetworkCred = new NetworkCredential( a @ gmail.com, r);
smtp.UseDefaultCredentials = true ;
smtp.Credentials = NetworkCred;
smtp.Port = 587 ;
smtp.Send(msg);
Response.Write( msg snd ........);
// Session [temp1] = Usernametxt.Text;
// 会话[temp2] = emailtxt.Text;
// Response.Redirect(http:// localhost:62874 / MapExtractor / MsgSendPage.aspx);
}
解决方案
可以这些链接帮助?
看看:
文章
通过ASP.NET发送带有嵌入式映像的电子邮件 [ ^ ]
Add-Image-Email.as px [ ^ ]
和一些类似的帖子
send-email-with-multi-attachments-stored-in-database-asp-net-c [ ^
I want to save images to the database and that images can be loaded to user created folder,then we have to select the image and send to the mail.
I use the following code,
protected void Upload_Click(object sender, EventArgs e)
{
String s = (String)Session["temp"];
if (FileUpload1.HasFile)
{
// string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
// FileUpload1.PostedFile.SaveAs(Server.MapPath("~/" + s + "\\") + fileName);
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
path = Server.MapPath("~/" + s + "\\") + fileName;
FileUpload1.SaveAs(path);
Response.Redirect(Request.Url.AbsoluteUri); insert imges
// Session["PATH"] = path;
}
protected void Send_Click(object sender, EventArgs e)
{
String sndps=(String)Session["pswd"];
// String s = (String)Session["PATH"];
String s = (String)Session["temp"];
String em = (String)Session["email"];
//TextBox1.Text = em;
MailMessage msg = new MailMessage();
string ActivationUrl = string.Empty;
string emailid = string.Empty;
SmtpClient smtp = new SmtpClient();
string emailId = em;
msg.From = new MailAddress("a@gmail.com");
msg.To.Add(em);
msg.Subject = "Conformation mail";
msg.Body ="Your Login Password is:"+sndps;
msg.IsBodyHtml = true;
// string[] files = Directory.GetFiles(path);
/*foreach (string file in files)
{
Console.WriteLine(file);
}*/
// msg.Attachments.Add( files);
//new Attachment(files));
//// if (FileUpload1.HasFile)
//// {
// msg.Attachments.Add(new Attachment(files.));
//// }
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("a@gmail.com", "r");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(msg);
Response.Write("msg snd........");
//Session["temp1"] = Usernametxt.Text;
//Session["temp2"] = emailtxt.Text;
//Response.Redirect("http://localhost:62874/MapExtractor/MsgSendPage.aspx");
}
解决方案
can these links help?
take a look:
articles
Sending email with an embedded image through ASP.NET[^]
Add-Image-Email.aspx[^]
and some similar posts
sending-email-with-multiple-attachments-stored-in-database-asp-net-c[^]
这篇关于数据库如何加载和显示图像.in asp.net ..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文