Hi,
Please check this sample code :
- <%@ Page Language="C#" Title="First sample" %>
-
- <%@ Import Namespace="CuteWebUI" %>
- <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
-
- <script runat="server">
- protected void Button1_Click(object sender, EventArgs e)
- {
- System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
- msg.From = "[email protected]";
- msg.To = "[email protected]";
- msg.Subject = tbTitle.Text;
- msg.Body = tbMessage.Text;
-
- foreach (AttachmentItem item in UploadAttachments1.Items)
- {
- if (!item.Checked) continue;
-
- //string filename = item.FileName;
- //int filesize=item.FileSize;
- //Stream stream=item.OpenStream();
-
- System.Web.Mail.MailAttachment ma
- = new System.Web.Mail.MailAttachment(item.GetTempFilePath());
- msg.Attachments.Add(ma);
- }
- //System.Web.Mail.SmtpMail.Send(msg);
-
- //remove all items
- //UploadAttachments1.DeleteAllAttachments();
-
-
- }
-
- </script>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- </head>
- <body>
- <form id="Form1" runat="server">
- <table>
- <tr>
- <td>
- </td>
- <td>
- Send a mail:
- </td>
- </tr>
- <tr>
- <td>
- Title :
- </td>
- <td>
- <asp:TextBox runat="server" ID="tbTitle"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" InsertText="Select attachments">
- <ItemCellStyle CssClass="Cell" />
- <TableStyle CssClass="Table" />
- </CuteWebUI:UploadAttachments>
- </td>
- </tr>
- <tr>
- <td>
- Message :
- </td>
- <td>
- <asp:TextBox runat="server" ID="tbMessage" Rows="8" TextMode="MultiLine" Width="400px"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send" Width="107px" />
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Regards,
Terry