日期:2011-09-14 浏览次数:20431 次
最近有个涉及到邮件的活,需要把文件上传到数据库,然后再把文件从数据库里面读出来,进行下载。
找了一些资料之后运用到项目当中。
数据库的结构如下:
USE [EOffice]
GO
/**//****** 对象: Table [dbo].[Group_Files] 脚本日期: 07/20/2006 23:57:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Group_Files](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FileName] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_Group_Files_FileName] DEFAULT (''),
[FileBody] [image] NULL,
[FileType] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_Group_Files_FileType] DEFAULT (''),
CONSTRAINT [PK_Group_Files] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
然后我写了一个存储过程,代码如下:
USE [EOffice]
GO
/**//****** 对象: StoredProcedure [dbo].[SendTo_Group_Email] 脚本日期: 07/20/2006 23:59:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create PROCEDURE [dbo].[SendTo_Group_Email]
(
@Title varchar(200),
@Content varchar(MAX),
@Area varchar(max),
@Sender varchar(50),
@Dept varchar(50),
@SendToUser varchar(50),
@FileName varchar(200),
@FileBody image,
@FileType varchar(4)
)
AS
INSERT Group_Email (Title,[Content],Area,SendToUser,Dept,Sender,FileName,FileBody,FileType) VALUES (@Title,@Content,@Area,@SendToUser,@Dept,@Sender,@FileName,@FileBody,@FileType)
程序代码如下:
SendEmail.aspx
1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SendEmail.aspx.cs" Inherits="GroupWork_SendEmail" %>
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6
7<head runat="server">
8 <title>发送邮件</title>
9<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
10body,td,th {
11 font-size: 9pt;
12}
13body {
14 background-image: url();
15 background-color: #F2F7FB;
16 margin-left: 10px;
17 margin-top: 5px;
18 margin-right: 10px;
19 margin-bottom: 5px;
20}
21-->
22</style></head>
23<script language="vbscript">
24function Select_Local_User(url)
25 dim k
26 k=showModalDialog(url,"","dialogWidth:485px;status:no;dialogHeight:280px")
27 if ubound(split(k,"$#@&!"))>=0 then
28 document.form1.HiddenField1.value = split(k,"$#@&!")(0)
29 document.form1.txtLocalUser.value = split(k,"$#@&!")(1)
30 end if
31end function
32
33function Select_Remote_User(url)
34 dim k
35 k=showModalDialog(url,"","dialogWidth:485px;status:no;dialogHeight:310px")
36 if ubound(split(k,"$#@&!"))>=0 the