Hi
I am using asp.net 2.0 - the following is the code for sending email with attachment - I placed the HTML portion in an UPdate panel
everything ok, mail succesfully delivered to the recipient-
BUT PROBLEM IS THE UPDATEPROGRESS CONTROL IS NOT WORKING AT ALL
WHAT WENT WRONG
<%@ Page Language="VB" %>
<%@ Import namespace="System.Net.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS
'Make sure a file has been uploaded
If String.IsNullOrEmpty(FileUpload1.FileName) OrElse FileUpload1.PostedFile Is Nothing Then
Throw New ApplicationException("Egad, a file wasn't uploaded... you should probably use more graceful error handling than this, though...")
End If
Const ToAddress As String = "sheriefes@ascorpuae.com"
'(1) Create the MailMessage instance
Dim mm As New MailMessage("test@ascorpuae.com", ToAddress)
'(3) Create the SmtpClient object
Dim smtp As New SmtpClient
'4: 'Attach the file
mm.Attachments.Add(New Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName))
'(5) Send the MailMessage (will use the Web.config settings)
smtp.Timeout = 200000 'in milli seconds
smtp.Send(mm)
Label1.Text = "Message Sent" : upTenant.Update()
End Sub
</script>
Bookmarks