代码如下:
 Dim popMail As jmail.POP3Class = New jmail.POP3Class
        Dim mailMessage As jmail.Message
        Dim atts As jmail.Attachments
        Dim att As jmail.Attachment
        Dim con As System.Data.SqlClient.SqlConnection
        Dim strcmd As String
        Dim cmd As System.Data.SqlClient.SqlCommand
        con = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("Sample"))
        'Try
        popMail.Connect("china91ad", "1978221", "webmail.china91.com", 110)
        If 0 < popMail.Count Then
            Dim i As Integer = 1
            While i <= popMail.Count
                mailMessage = popMail.Messages(i)
                atts = mailMessage.Attachments
                mailMessage.Charset = "GB2312"
                mailMessage.Encoding = "Base64"
                mailMessage.ISOEncodeHeaders = False
                strcmd = "insert email (emltitle,emlform,emlformname,subject,body) values (@emltitle,@emlform,@emlformname,@subject,@body)"
                cmd = New System.Data.SqlClient.SqlCommand(strcmd, con)
                cmd.Parameters.Add("@emltitle", System.Data.SqlDbType.VarChar).Value = mailMessage.Subject
                cmd.Parameters.Add("@emlform", System.Data.SqlDbType.VarChar).Value = mailMessage.From
                cmd.Parameters.Add("@emlformname", System.Data.SqlDbType.VarChar).Value = mailMessage.FromName
                cmd.Parameters.Add("@subject", System.Data.SqlDbType.VarChar).Value = mailMessage.Subject
                cmd.Parameters.Add("@body", System.Data.SqlDbType.VarChar).Value = mailMessage.Body
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
                'txtpriority.Text = mailMessage.Priority.ToString
                'txtSendMail.Text = mailMessage.From
                'txtSender.Text = mailMessage.FromName
                'txtSubject.Text = mailMessage.Subject
                'txtBody.Text = mailMessage.Body
                'txtSize.Text = mailMessage.Size.ToString
                Dim j As Integer = 0                While j < atts.Count
                    att = atts(j)
                    Dim intfilelen As Integer
                    Dim objstream As System.IO.Stream
                    intfilelen = att.Size
                    Dim arrfile(intfilelen) As Byte
                    objstream = att
                    objstream.Read(arrfile, 0, intfilelen)
                    Dim attname As String = att.Name
                    strcmd = "insert attfile(attname,attfile) values (@attname,@attfile)"
                    cmd = New System.Data.SqlClient.SqlCommand(strcmd, con)
                    cmd.Parameters.Add("@attname", System.Data.SqlDbType.VarChar).Value = attname
                    cmd.Parameters.Add("@attfile", System.Data.SqlDbType.Image).Value = arrfile
                    con.Open()
                    cmd.ExecuteNonQuery()
                    con.Close()
                    'att.SaveToFile("e:\attFile\" + attname)
                    'System.Math.Min(System.Threading.Interlocked.Increment(j), j - 1)
                End While
                'System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
            End While
            'panMailInfo.Visible = True
            att = Nothing
            atts = Nothing
        Else
            Response.Write("没有新邮件!")
        End If
        popMail.DeleteMessages()
        popMail.Disconnect()
        popMail = Nothing
        'Catch
        'Response.Write("Warning!请检查邮件服务器的设置是否正确!")
        'End Try
    End Sub错误如下:指定的转换无效。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidCastException: 指定的转换无效。源错误: 
行 65:                     intfilelen = att.Size
行 66:                     Dim arrfile(intfilelen) As Byte
行 67:                     objstream = att
行 68:                     objstream.Read(arrfile, 0, intfilelen)
行 69:                     Dim attname As String = att.Name
 
提示67行出错,请问各位如何转换格式
谢谢