web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Business Central Attach Email Body

JAngle Profile Picture JAngle 133

I recently did a post about how BC works with emails for CRM mostly. Check it out here: https://joshanglesea.wordpress.com/2022/07/01/business-central-crm-email-%f0%9f%93%a8/
This got me thinking about another scenario which I get asked about from time to time by prospective clients. If a customer/contact emails something important can you then attach that to a record in BC?

Now, I accept that attaching in BC is a nice user feature but I also appreciate long term it will build up the database size. I’m leaning towards the practical side of the argument in that checking emails in the interaction log entries isn’t that intuitive (check the referenced blog to understand more). Checking the attachments of a document or master record is though. Especially for critical information like a purchase order reference for a sales order. My idea for a solution stems from the wave 1 2022 release of this functionality – to save you checking it allows users to take email attachments into BC attachments for records: https://docs.microsoft.com/en-us/dynamics365-release-plan/2022wave1/smb/dynamics365-business-central/outlook-add-in-add-attachments-emails-directly-business-central-documents

If you have used the BC outlook add-in you will probably know about the “Suggested Line Items” feature. This is where you choose to create a new sales document and it reads the email body to find matches for items in the company. I’m mentioning this because the two features I’ve brought up resulted in my answer.
My scenario with an example. Here is an email exchange between Tim who is a BC user and his customer. They want to progress with the order and have responded with their Purchase Order reference with.
Using the BC Outlook add-in the user finds the Sales Order and follows the steps shown above – clicks on the ellipsis icon, scrolls and locates “Attachments”, finds a new button called “Attach email body”.
This will add the html of the email as an attachment record. I used the current date and time in conjunction with the email subject to create the name of the attachment. You could use something else of course.
Users aren’t able to view the attachments in the BC Outlook add-in – be it html or not. This is the message which pops up if they try.
However, in the BC web client a user can work with the attachment as normal by clicking on it to download, share or open in OneDrive. Given it is a HTML file I have added an extra option, which makes the most of a standard feature. The new button is “Preview Email” and it displays the HTML attachment. Granted it’s not perfect but it’s a quick and effective way of viewing the details without having to go rooting around in the interaction log entries
I’ve made it so the “enabled” property of the page action only works with files that have the html “File Extension”.

Like what you see? Want to try it out? You can find the code here: https://github.com/JAng13sea/Blogs/tree/master/Email%20Body

I attempted to make the HTML nicer by using https://www.hougaard.com/wysiwyg/ but the result was the same as the standard preview. If like me you want to have the preview formatted correctly you will need to try a different approach – which is another copy of how standard BC does it.

Here is how the preview page looks when it is passed the text value from a report object instead – which is then saved as HTML. Code for this one is on github too.

This was originally posted here.

Comments

*This post is locked for comments