Email compose form with attachment uploader. Files appear as compact chips
below the compose area. Uses Web Forms controls for the email fields.
What you should see: an "Attach Files" flow for a compose screen - multiple files, immediate upload, each listed as an attachment chip.
<au:AjaxFileUpload ID="Uploader1" runat="server"
AllowMultiple="true" AutoUpload="true" ButtonText="Attach Files" />
<asp:Button ID="BtnSend" runat="server" Text="Send" OnClick="BtnSend_Click" />
protected void BtnSend_Click(object sender, EventArgs e)
{
using (var msg = new System.Net.Mail.MailMessage())
{
foreach (var item in Uploader1.Items)
{
msg.Attachments.Add(new System.Net.Mail.Attachment(
item.OpenStream(),
Path.GetFileName(item.FileName),
item.ContentType));
}
// configure <mailSettings>, set From/To, then:
// new System.Net.Mail.SmtpClient().Send(msg);
}
}
Upgrading from v4? Your existing code keeps working with the
CuteWebUI markup - no rewrite needed:
<%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>
<CuteWebUI:UploadAttachments ID="Uploader1" runat="server" />
foreach (AttachmentItem item in Uploader1.Items)
{
string fileName = Path.GetFileName(item.FileName);
mailer.Message.Attachments.Add(item.OpenStream(), fileName, ...);
}