I am using workflow to generate a csv file which is saved to a network folder. I'm wanting to email this same file as part of the workflow, but I'm unable to attach the file via Email activity.
I realize I can use Import Agent to retrieve the file from the network folder, but that seems like a lot of opportunities for failure, so I would like to avoid this.
Also, I would like to save the file to a network folder AND to Laserfiche if possible. Below is the code I'm using to generate the CSV file. My vb.Net is not great, but it works for my needs. If you have any suggestions on improving this script, please let me know.
Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Data.SqlClient Imports System.Text Imports Laserfiche.RepositoryAccess Namespace WorkflowActivity.Scripting.SDKScript '''<summary> '''Provides one or more methods that can be run when the workflow scripting activity is performed. '''</summary> Public Class Script1 Inherits RAScriptClass92 '''<summary> '''This method is run when the activity is performed. '''</summary> Protected Overrides Sub Execute() 'Wrap the code in a Try/Catch to catch any errors... Try 'Instantiate a new streamwriter... Dim csvWriter As New System.IO.StreamWriter("\\prodlfqf\Attachments\Magna Orders\Magna Order " & me.GetTokenValue("Order Number").ToString & ".csv") Dim headerRow As String 'Will hold the header row values Dim orderRow() as string = me.GetTokenValue("PatternMatching_Order Number") 'Will hold the order data row Dim shipDate() as String = me.GetTokenValue("PatternMatching_Shipped on") 'Will hold the ship date Dim csvData As New StringBuilder 'We will append all of the data to this string object 'Here is the order row... For n as Integer = 0 to orderRow.GetUpperBound(0) csvData.AppendLine("Order Number: " & orderRow(n)) csvData.AppendLine("Shipped on: " & shipDate(n)) Next n 'Here is the header row... headerRow = "Line Number, Product Number ,Quantity Ordered, Quantity Shipped, Lot #" csvData.AppendLine(headerRow) dim myLineNumbers() as String = me.GetTokenValue("PatternMatching_Line Number") dim myProductNumbers() as String = me.GetTokenValue("PatternMatching_Product Number") dim myQuantityOrdered() as String = me.GetTokenValue("PatternMatching_Quantity Ordered") dim myQuantityShipped() as String = me.GetTokenValue("PatternMatching_Quantity Shipped") dim myLotNumbers() as String = me.GetTokenValue("PatternMatching_Lot #") For i as Integer = 0 To myLineNumbers.GetUpperBound(0) csvData.AppendLine(myLineNumbers(i) & "," & myProductNumbers(i) & "," & myQuantityOrdered(i) & "," & myQuantityShipped(i) & "," & myLotNumbers(i)) Next i 'Now write the CSV file and close the streamwriter... csvWriter.Write(csvData) csvWriter.Close 'Cleanup... csvWriter = Nothing csvData = Nothing Catch ex As Exception 'Send any error messages to workflow so they can be tracked... WorkflowApi.TrackError(ex.message) End Try 'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session End Sub End Class End Namespace
Nate