All,
My web app sends many many emails. Usually PDF, Excel, Word, etc. This is the first time I need to send a Zip file. Every time I send I zip file through code, when I get the zip in my email, then try to unzip it, I get a message saying that the CRC is bad and the file is corrupt. Interestingly enough, *.Rar files come through fine. But I can't use these as I cannot guarantee our clients use WinRar.
Anyone ever have any success sending an email with a zip file attachment in Asp.Net using IIS? I've tried sending through our Exchange server as well as through the Smtp host of the T1 provider. Same results, everytime the zip file in the email is corrupt.
For those interested here is a simplified version of the sub that I use to send the email:
* Sine scientia ars nihil est
* Respondeat superior
My web app sends many many emails. Usually PDF, Excel, Word, etc. This is the first time I need to send a Zip file. Every time I send I zip file through code, when I get the zip in my email, then try to unzip it, I get a message saying that the CRC is bad and the file is corrupt. Interestingly enough, *.Rar files come through fine. But I can't use these as I cannot guarantee our clients use WinRar.
Anyone ever have any success sending an email with a zip file attachment in Asp.Net using IIS? I've tried sending through our Exchange server as well as through the Smtp host of the T1 provider. Same results, everytime the zip file in the email is corrupt.
For those interested here is a simplified version of the sub that I use to send the email:
Code:
Private Sub SimpleSendEmail()
Dim NetworkCred As NetworkCredential = New System.Net.NetworkCredential()
NetworkCred.UserName = "MyEmail@Domain.com"
NetworkCred.Password = "MyPassword"
Dim oEmail As New System.Net.Mail.MailMessage()
oEmail.From = New MailAddress("MyEmail@Domain.com")
oEmail.To.Add("MyEmail@Domain.com")
oEmail.Subject = "This is an email"
oEmail.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>"
oEmail.IsBodyHtml = True
oEmail.Priority = System.Net.Mail.MailPriority.High
Dim oClient As New SmtpClient("smtp.server.com")
oClient.UseDefaultCredentials = True
oClient.Port = 587
oClient.EnableSsl = True
oClient.Credentials = NetworkCred
Dim oAttachment As System.Net.Mail.Attachment
oAttachment = New System.Net.Mail.Attachment("C:\Temp\SampleFile.zip")
oAttachment.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable
oEmail.Attachments.Add(oAttachment)
Try
oClient.Send(oEmail)
Catch ex As Exception
Dim ai As New AddlErrInfo
ai.Add("Host", oClient.Host)
ai.Add("Port", oClient.Port.ToString)
AppError.GenericApplicationError(ex, ai)
Finally
oEmail = Nothing
oClient.Dispose()
End Try
End Sub
* Sine scientia ars nihil est
* Respondeat superior