Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
asp.net vb-电子邮件接收上的docx corrupotion_Asp.net_Vb.net - Fatal编程技术网

asp.net vb-电子邮件接收上的docx corrupotion

asp.net vb-电子邮件接收上的docx corrupotion,asp.net,vb.net,Asp.net,Vb.net,我试图通过我制作的表格发送Docx文件,电子邮件发送很好。 但是docx文件被破坏了。。 这是我的背景代码: '添加电子邮件相关类的命名空间 导入System.Net.Mail 部分类发送附件 继承System.Web.UI.Page Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click 'Make sure a file has

我试图通过我制作的表格发送Docx文件,电子邮件发送很好。 但是docx文件被破坏了。。 这是我的背景代码:

'添加电子邮件相关类的命名空间 导入System.Net.Mail

部分类发送附件 继承System.Web.UI.Page

Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click
    'Make sure a file has been uploaded
    If String.IsNullOrEmpty(AttachmentFile.FileName) OrElse AttachmentFile.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

    ' UPDATE THIS VALUE TO YOUR EMAIL ADDRESS
    Const ToAddress As String = "pelleg@shakuff.co.il"

    '(1) Create the MailMessage instance
    Dim mm As New MailMessage(UsersEmail.Text, ToAddress)

    '(2) Assign the MailMessage's properties
    mm.Subject = "שלוחת קורות חיים"
    mm.Body = Body.Text
    mm.IsBodyHtml = False

    'Attach the file
    mm.Attachments.Add(New Attachment(AttachmentFile.PostedFile.InputStream, AttachmentFile.FileName))

    '(3) Create the SmtpClient object
    Dim smtp As New SmtpClient

    '(4) Send the MailMessage (will use the Web.config settings)
    smtp.Send(mm)


    'Show the EmailSentForm Panel and hide the EmailForm Panel
    EmailSentForm.Visible = True
    EmailForm.Visible = False
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        'On the first page load, hide the EmailSentForm Panel
        EmailSentForm.Visible = False
    End If
End Sub
末级

它是sendmail.aspx.vb文件。
有什么建议吗?

我完全想不到,但请尝试设置:

AttachmentFile.PostedFile.InputStream.Position = 0  
打电话之前:

'Attach the file     mm.Attachments.Add(New Attachment(AttachmentFile.PostedFile.InputStream, AttachmentFile.FileName))