[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

asp.net file upload problem

Asked by dany_L in Programming for ASP.NET, Microsoft IIS Web Server

Tags: asp.net, 'file upload', vb.net, upload, attachments

Hi!,

I have a web form used to upload a file and send the attachments to an email address, the form works well and the attachments are sent fine, the problem it is bringing the Application Pool down after some time, it can take days, the first time  took one week to bring the Pool down, sometimes only take hours. I don't see anything on the Event Log.

I also tried to save the attachments in the server and from memory and got the
same problem.

My SMTP server is in another computer,  a portion of the code is below.
I am using .NET framework 2.0 IIS 6.0 on Windows 2003 Server.

Your input is highly appreciated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
Sub SendEmail(ByVal strFrom As String, ByVal strTo As String, _
    ByVal strSubj As String, ByVal strDesc1 As String, ByVal strDesc2 As String, ByVal strDesc3 As String)
 
        '*---------------- Send email to user ------------------*
        From = strFrom
        ToAddr = strTo
        Subj = strSubj
        '*---------------- body Information --------------------*
        sComments1 = strDesc1
        sComments2 = strDesc2
        sComments3 = strDesc3
 
        'create the mail message
        Dim mail As New System.Net.Mail.MailMessage  ' MailMessage()
        Dim strBody As String = Body
 
        'set the addresses
        mail.From = New MailAddress(From)
        mail.To.Add(ToAddr)
 
        Dim strCC As String = Trim(ConfigurationManager.AppSettings("CCAddress").ToString)
        If Not (strCC = "") Then
            mail.CC.Add(strCC)
        End If
 
        mail.Priority = Net.Mail.MailPriority.High
        'set the content
        mail.Subject = Subj
 
        '** add attachments
        Dim newFileName As String = Nothing
        Dim fStream As FileStream = Nothing
        Dim fileType As String = Nothing
        Dim fileSize As String = Nothing
        Dim fileExt As String = ""
 
        Dim i As Integer = 0
        Dim fileNames As New ArrayList
        Dim uploadedFiles As HttpFileCollection = Request.Files
 
        Do Until i = uploadedFiles.Count
            Dim userPostedFile As HttpPostedFile = uploadedFiles(i)
 
            If userPostedFile.ContentLength > 0 Then
                newFileName = System.Guid.NewGuid().ToString()
 
                fileType = userPostedFile.ContentType
                fileExt = Me.GetFileExtension(userPostedFile.FileName)
                newFileName = newFileName + "." + fileExt
 
                Dim numBytes As Integer = CInt(userPostedFile.InputStream.Length)
                Dim buffer As Byte() = New Byte(numBytes - 1) {}
                userPostedFile.InputStream.Read(buffer, 0, numBytes)
 
                Dim FullPath As String = Server.MapPath(LOCAL_DIRECTORY) + "\" + newFileName
 
                fileNames.Add(FullPath)
 
                fStream = New FileStream(FullPath, FileMode.Create)
                fStream.Write(buffer, 0, numBytes)
                fStream.Close()
 
                Dim attachmt1 As New System.Net.Mail.Attachment(FullPath)
                mail.Attachments.Add(attachmt1)
            End If
            i += 1
        Loop
 
        ' end attachments
 
        '** first we create the Plain Text part
        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", Nothing, "text/plain")
        Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("<img src=cid:companylogo><br><br>" & vbCrLf + sComments1 + "<br>" + sComments2 + "<br>" + "<br>" + "Problem or Service Description: " + "<br>" + sComments3 + "<br>" + "<br>" + "Your quick attention is appreciated:" + "<a href='http://" & Request.ServerVariables("HTTP_HOST") & "/Vaf/GMOApproval.aspx?id=" & "' ></a>" + " " + "<br>" + "<br>", Nothing, "text/html")
 
        '** Get server Path
        Dim path2 As String = Server.MapPath("~") & "\"
        Dim filename As String = path2 & "images\img_default.png"
 
        '** create the LinkedResource (embedded image)
        Dim logo As New LinkedResource(filename)
        logo.ContentId = "companylogo"
 
        '** add the LinkedResource to the appropriate view
        htmlView.LinkedResources.Add(logo)
 
        '' ** add the views
        mail.AlternateViews.Add(htmlView)
        mail.AlternateViews.Add(plainView)
 
        '** send the message
        Dim strSMTPServer As String = ConfigurationManager.AppSettings("SMTPServer")
        Dim smtp As New SmtpClient(Trim(strSMTPServer)) 'specify the mail server address
        smtp.Send(mail)
 
        'If mail.Attachments.Count > 0 Then
        '    For Each att As Attachment In mail.Attachments
        '        att.Dispose()
        '    Next
        'End If
 
     ...
 
        mail = Nothing
        smtp = Nothing
[+][-]06/04/09 06:58 AM, ID: 24546966Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, Microsoft IIS Web Server
Tags: asp.net, 'file upload', vb.net, upload, attachments
Sign Up Now!
Solution Provided By: strickdd
Participating Experts: 3
Solution Grade: A
 
[+][-]06/04/09 06:59 AM, ID: 24546968Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06/04/09 01:38 PM, ID: 24551204Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/05/09 02:40 AM, ID: 24554696Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/28/09 05:48 AM, ID: 25206951Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625