Skip to main content
Newcomer
July 28, 2023
Solved

Send Email - Attach files from File Explorer

  • July 28, 2023
  • 2 replies
  • 0 views

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?

 

Anusha_MP_5-1690546930184.png

 

Anusha_MP_0-1690545979806.png

Regards,

Anusha

Best answer by RobbSalzmann

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:

VB

 

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
}

 

C#

 

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};

 

 

 

 

 

 

2 replies

aricgresko
Veteran
July 28, 2023

Have you considered just using Parcel Service to do this? 

Anusha_MPAuthor
Newcomer
July 28, 2023

Nope, I haven't 

aricgresko
Veteran
July 28, 2023

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. 

RobbSalzmann
Legend
August 1, 2023

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:

VB

 

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
}

 

C#

 

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};

 

 

 

 

 

 

Anusha_MPAuthor
Newcomer
August 5, 2023

Thanks a lot!

-Anusha