Vb.net 无效邮件附件

Vb.net 无效邮件附件,vb.net,email,windows-services,Vb.net,Email,Windows Services,我有一个windows服务,它通过从数据库中检索记录来发送电子邮件。Windows服务运行的服务帐户是该计算机上的本地管理员。我遇到的问题是,windows服务设法发送了一些带有pdf附件的电子邮件,这些电子邮件存在于windows服务所在的本地服务器上,对于大多数电子邮件,我会收到一条错误消息:对不起,伙计们,我已经找到了答案,这是我的错,因为我在不同的服务器上运行了两个不同版本的windows服务,它们都从数据库中提取附件,并且路径存在于一台保存文件的服务器上,而不存在于另一台服务器上,这就

我有一个windows服务,它通过从数据库中检索记录来发送电子邮件。Windows服务运行的服务帐户是该计算机上的本地管理员。我遇到的问题是,windows服务设法发送了一些带有pdf附件的电子邮件,这些电子邮件存在于windows服务所在的本地服务器上,对于大多数电子邮件,我会收到一条错误消息:对不起,伙计们,我已经找到了答案,这是我的错,因为我在不同的服务器上运行了两个不同版本的windows服务,它们都从数据库中提取附件,并且路径存在于一台保存文件的服务器上,而不存在于另一台服务器上,这就是为什么一些电子邮件被管理为已发送。

服务的代码将是一个很好的开始。我已按照您的要求提供了上述代码。如果您循环并添加附件,请尝试取出整个:New System.Net.Mail.attachment,然后放入您的strAttachment。我可以尝试这样做,然而,我想问,如果有一个无效的附件,它会抛出一个异常吗?是的,它会,但它可以源于许多事情。。。。u p可以发布问题的堆栈跟踪吗? Invalid Mail Attachment
Try

        ' Initialize new mail message class
        Dim objEmailMessage As New System.Net.Mail.MailMessage(EmailOutboxEntity.EmailFrom, EmailOutboxEntity.EmailTo)

        ' Set the email parameters
        objEmailMessage.Subject = EmailOutboxEntity.EmailSubject
        objEmailMessage.Body = EmailOutboxEntity.EmailBody

        ' Check if attachments have been specified
        If Not EmailOutboxEntity.TestOriginalFieldValueForNull(EmailOutboxFieldIndex.EmailAttachements) Then

            ' Get an array of attachment file names to send
            Dim arrAttachment As String() = Split(EmailOutboxEntity.EmailAttachements, CONST_AttachmentSeparator)

            ' Step through each filename and attach it to the email
            For Each strAttachment As String In arrAttachment

                ' Attach the current file to the email
                objEmailMessage.Attachments.Add(New System.Net.Mail.Attachment(strAttachment))

            Next

        End If

        ' Set the SMTP server
        Dim mailServer As New System.Net.Mail.SmtpClient(pstrSMTPServer)

        ' Send the message
        mailServer.Send(objEmailMessage)

    Catch errException As Exception

        ' Throw an exception indicating the email failed to send
        Throw New EmailOutboxManagerException(errException.Message, "Test Failed to send email, got the following error instead:")

    End Try