03-05-2024 12:42 PM
Hi,
Is it possible to attach a file from the public folder to the mail using the function,
BRApi.Utilities.SendMail(si, emailConnectionName, toEmailAddresses, subject, body, attachmentFilePaths)
Would appreciate any assistance.
Thank You.
03-05-2024 02:19 PM - edited 03-05-2024 02:27 PM
Hi @Shivangi Here's an extender sample to help get you started
Namespace OneStream.BusinessRule.Extender.SendMail
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
Dim fileFullName As String = "EmailAttachment.png"
Dim failGracefully As Boolean = True
Dim includeContentFileBytes As Boolean = True
Dim objXFFileEx As XFFileEx = BRApi.FileSystem.GetFile(si, FileSystemLocation.ApplicationDatabase, fileFullName, includeContentFileBytes, failGracefully)
Dim fullNamePath As String = objXFFileEx.XFFile.FileInfo.FullName
Dim attachmentFilePaths As List(Of String) = New List(Of String)() From {
fullNamePath
}
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
03-06-2024 09:12 AM
Hi, Thank You for providing the snippet. I tried this way to attach my file, I was getting the File path as well but when I pass the filepath in the BRApi.Utilities.SendMail(...) function I was getting an error.
Could not find a part of the path 'C:\Program Files\OneStream Software\OneStreamAppRoot\OneStreamApp\Documents\Public\File.csv
03-06-2024 09:50 AM - edited 03-06-2024 09:50 AM
Based on the code you posted, this error is not possible. Its coming from somewhere else.
Using your code...
Dim failGracefully As Boolean = True
Dim includeContentFileBytes As Boolean = True
Dim objXFFileEx As XFFileEx = BRApi.FileSystem.GetFile(si, FileSystemLocation.ApplicationDatabase, "Documents\Public\File.csv", includeContentFileBytes, failGracefully)
Dim fullNamePath As String = objXFFileEx.XFFile.FileInfo.FullName
BRApi.ErrorLog.LogMessage(si, fullNamePath) 'gives "Documents/Public/File.csv" in the error log.
03-08-2024 04:40 AM
Hi, I tried once again. I'm getting the File information and Path as well but I am not able to send it via mail. Getting the same error mentioned above.
04-01-2024 09:54 AM
Hi Shivangi,
I am facing the same issue that its picking my local system's path. Were you able to rectify it?
Regards,
Rashi