SMTP Multiple Attachments

liunx

Guest
I have setup a web based email submission application that submits SMTP emails based on a ASP.NET (using VB) form. Would anyone be able to tell me why users would be able to successfully submit with up to one attachment but not with two or three? Below I have the code for attaching the attachments. Currently the application is running from my localhost and I can send as many attachments as desired, however, the remote users can only send 0-1 attachments. thank you in advance for your help:


Dim attach1 As String
Dim attach2 As String
Dim attach3 As String
Dim strPath As String = "C:\ServerFolder\"

'Attaches file 1
If File1.Value <> "" Then
Dim strFileName As String = File1.PostedFile.FileName
Dim c As String = System.IO.Path.GetFileName(strFileName)
Try
File1.PostedFile.SaveAs(strPath & c)
Catch Exp As Exception
Response.Write("Error" & Exp.Message)
End Try
Mail.Attachments.Add(New MailAttachment(strPath & c))

attach1 = (strPath & c)
End If

'Attaches file 2
If (File2.Value <> "") Then
Dim strFileName2 As String = File2.PostedFile.FileName
Dim c2 As String = System.IO.Path.GetFileName(strFileName2)
Try
File2.PostedFile.SaveAs(strPath & c2)
Catch Exp As Exception
Response.Write("Error" & Exp.Message)
End Try
Mail.Attachments.Add(New MailAttachment(strPath & c2))

attach2 = (strPath & c2)
End If

'Attaches file 3
If (File3.Value <> "") Then
Dim strFileName3 As String = File3.PostedFile.FileName
Dim c3 As String = System.IO.Path.GetFileName(strFileName3)
Try
File3.PostedFile.SaveAs(strPath & c3)
Catch Exp As Exception
Response.Write("Error" & Exp.Message)
End Try
Mail.Attachments.Add(New MailAttachment(strPath & c3))

attach3 = (strPath & c3)
End If

'Sends the email
SmtpMail.SmtpServer = "mail.server.com"
SmtpMail.Send(Mail)

'Deletes attachments from server
If attach1 <> "" Then
File.Delete(attach1)
End If

If attach2 <> "" Then
File.Delete(attach2)
End If

If attach3 <> "" Then
File.Delete(attach3)
End If
 
Back
Top