私はDevExpressツール、特に必要なすべてのデータを返す「SelectedFiles」プロパティを持つFileManager(レコードの追加、挿入、削除、取得、変更)を使用しています。ただし、選択したファイルを MailMessage.Attachment として使用する方法がわかりません。以下のコードは、電子メールを送信するために機能します。セキュリティのために資格情報とホストの値を変更しました。「SelectedFiles」を介して生成された FileManager コレクションを使用し、それらを電子メールの添付ファイルとして追加する方法について、指示または考えが必要です。可能であればファイルを圧縮したいのですが、この時点では単に添付するだけで問題ありません。何かご意見は?
Dim fileManager As ASPxFileManager = TryCast(sender, ASPxFileManager)
If ASPxFileManager1.SelectedFiles IsNot Nothing AndAlso ASPxFileManager1.SelectedFiles.Length > 0 Then
For i As Integer = 0 To ASPxFileManager1.SelectedFiles.Length - 1
Dim file = ASPxFileManager1.SelectedFiles.ToString
Dim attachments As New Attachment(fileManager.SelectedFiles.ToString)???
Next
End If
Try
Dim mail As New MailMessage("noreply", DropDownEdit.Text)
Dim smtp_Server As New SmtpClient("host") With {.Credentials = New Net.NetworkCredential("username", "password")}
mail.Subject = "SUBJECT"
mail.IsBodyHtml = False
mail.Body = "Testing"
smtp_Server.Send(mail)
successLabel.Text = "Your email was sent successfully."
Catch ex As Exception
End Try
End Sub