Re: Ajax Uploader

  •  10-14-2008, 1:37 AM

    Re: Ajax Uploader

    Please try based on this 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 = "mymail@myhost.com";
      msg.To = "yourmail@yourmail.com";
      msg.Subject = "Test";
      msg.Body = "Test";
      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);
     }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
     <form id="Form1" runat="server">
      <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" InsertText="UploadAttachments1">
      </CuteWebUI:UploadAttachments>
      <br />
      <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send" Width="107px" />
     </form>
    </body>
    </html>

     
View Complete Thread