07-28-2023 08:25 AM
I'm attempting to send an email with an attachment from a file stored in File Explorer. What does my file path look like if the file is saved in File Explorer->Application Database->Documents ->Public?
Regards,
Anusha
Solved! Go to Solution.
08-01-2023
09:10 AM
- last edited on
10-26-2023
05:40 AM
by
JackLacava
@Anusha_MP Files in the application database filesystem are stored in a table and accessible via the BRApi FileSystem object. As such, 'folder path' is more of an attribute than a real path to the file somewhere:
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 folderName As String = objXFFileEx.XFFile.FileInfo.FolderFullName 'Just an attribute
Dim bytes As Byte() = objXFFileEx.XFFile.ContentFileBytes
Dim att As Attachment = New Attachment(New MemoryStream(bytes), fileFullName)
Dim attachments As List(Of Attachment) = New List(Of Attachment)() From
{
att
}
string fileFullName = "EmailAttachment.png";
bool failGracefully = true;
bool includeContentFileBytes = true;
XFFileEx objXFFileEx = BRApi.FileSystem.GetFile(si, FileSystemLocation.ApplicationDatabase, fileFullName, includeContentFileBytes, failGracefully);
String folderName = objXFFileEx.XFFile.FileInfo.FolderFullName; // Just an attribute
Byte[] bytes = objXFFileEx.XFFile.ContentFileBytes;
Attachment att = new Attachment(new MemoryStream(bytes), fileFullName);
List<Attachment> attachments = new List<Attachment>(){att};
07-28-2023 08:42 AM
Have you considered just using Parcel Service to do this?
07-28-2023 08:52 AM
Nope, I haven't
07-28-2023 08:56 AM
Try Parcel Service. It does exactly what you want without having to write any code. You can also write an email body in the package and include substitution variables to make it dynamic.
07-31-2023 12:56 AM
Thanks a lot for your inputs. I would definitely try that, but just for knowledge purposes, I want to know how that file path should look like.
08-01-2023
09:10 AM
- last edited on
10-26-2023
05:40 AM
by
JackLacava
@Anusha_MP Files in the application database filesystem are stored in a table and accessible via the BRApi FileSystem object. As such, 'folder path' is more of an attribute than a real path to the file somewhere:
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 folderName As String = objXFFileEx.XFFile.FileInfo.FolderFullName 'Just an attribute
Dim bytes As Byte() = objXFFileEx.XFFile.ContentFileBytes
Dim att As Attachment = New Attachment(New MemoryStream(bytes), fileFullName)
Dim attachments As List(Of Attachment) = New List(Of Attachment)() From
{
att
}
string fileFullName = "EmailAttachment.png";
bool failGracefully = true;
bool includeContentFileBytes = true;
XFFileEx objXFFileEx = BRApi.FileSystem.GetFile(si, FileSystemLocation.ApplicationDatabase, fileFullName, includeContentFileBytes, failGracefully);
String folderName = objXFFileEx.XFFile.FileInfo.FolderFullName; // Just an attribute
Byte[] bytes = objXFFileEx.XFFile.ContentFileBytes;
Attachment att = new Attachment(new MemoryStream(bytes), fileFullName);
List<Attachment> attachments = new List<Attachment>(){att};
08-05-2023 10:06 AM
Thanks a lot!
-Anusha