169
Views
22
Comments
Solved
Sending a screen via email (similar to how you can print the entire)
Question
Application Type
Reactive

Hello all! I have an interesting problem. I have a screen that has a table and some user infor and I would like to have my app, on button click, send an email of a picture of the current screen. I would like it to be saved as a PDF as well. Can anyone point me in the right direction?

I have an option where I can download the screen into a PDF, upload the PDF to the app then email that, but that's a bit teduis..... I'm looking to hav a a button that would allow a user to send the screen via email as a pdf



2024-12-10 04-40-04
Gitansh Anand
Solution

Hi @Ide Fatsha, Look at this component. To use this wrap everting that you want to be a part of your PDF in a container, place the two blocks from the component above that container and pass the container's ID in the main block (the main block is a button). It will return the binary data of the PDF, which you can send as an attachment in your email template.

Thanks
Gitansh Anand

UserImage.jpg
Ide Fatsha

Where can I find the container ID

UserImage.jpg
Ide Fatsha

I was able to able to make the button download a pdf of the screen.. Now I want to send the pdf screen as an email....... Does the file get saved to some sort of database? I want to be able to send the file in an email without have to upload it first.... I want to do that with a button

2024-12-10 04-40-04
Gitansh Anand

Hi, First of all, in the screenshot, I can see you are using the main block twice; you need to replace one with the exec block if you have not done so already.
Now the exce block will have an event called "ReturnBinary, Create a handler for that event, and it will provide you the binary data without any need to upload it anywhere.

UserImage.jpg
Ide Fatsha

i fixed, It seems to be working now.... The button downloads a pdf of the current screen


Now I want to send the pdf screen as an email....... Does the file get saved to some sort of database? I want to be able to send the file in an email without have to upload it first.... I want to do that with a button 

2024-12-10 04-40-04
Gitansh Anand


Hi, Please look at the OML attached, What you need to do is set the inputs of the Exce block as in the below image and add an event handler. You can find the logic of the handler in the OML. 

Test.oml
UserImage.jpg
Ide Fatsha

My block doesn't have the input parameters in your block.... Do I add them on the module for the block? also what data types are they?


2024-12-10 04-40-04
Gitansh Anand

Hi, just remove the options paramter that you have correctly assigned, and then you will find a plus button beside the "Options" (refer to the image below), or you can assign the values to that option variable in the OnInitialize event of the screen.
If you still have any issue, may be you could upload your OML and I will modify it for you.

2024-12-10 04-40-04
Gitansh Anand

From what I can see, the OML you have attached should work fine. Are you getting some sort of error somewhere?

UserImage.jpg
Ide Fatsha

The email part doesn't seem to work at all.... The file would just be downloaded when I click on the  button..... I after I made the changes you suggested... I'm getting the below error when the button is done loading

2024-12-10 04-40-04
Gitansh Anand

Hi, try with this modified OML.
I have changed 2 input values (refer to the below image).

PDF sender.oml
2024-12-10 04-40-04
Gitansh Anand

In case this does not work, try adding a message "Html2Pdf_Js_ExecBlockReturnBinary" so that it can be identified if the problem is in generating the PDF or sending an email (refer to the image below).

UserImage.jpg
Ide Fatsha

It displayed the message before giving the same error message

UserImage.jpg
Ide Fatsha
2024-12-10 04-40-04
Gitansh Anand

It is clear that the component is working fine, the problem is in sending email.
I have a few suggestions.
1. The problem might be that the file size is large and because of that, it is taking a long time to download. For that reason, disable the email call and download the file generated with the new settings, then look at the size of the file. If it is too large, reduce the quality.
2. Trigger the email separately, once without attachment and once with attachment, and look what is happening.
3. Increase the request timeout value.
4. I am not sure if it will solve the issue, but add some UI to the email template.

2024-12-10 04-40-04
Gitansh Anand

The problem is most definitely because of the file size. As I observed on your page, the pdf being generated is 3.7 MB or more, and it may be because of that that you are getting a connection timeout. Please apply the settings I mentioned earlier (set type to ".jpeg" and quality to 0.5; refer to the image and OML shared before) and check again.

UserImage.jpg
Ide Fatsha

i have just downloaded the oml you shared eariler where you made the changes and it gave me the same error it did before ("Connection timed out")

2024-12-10 04-40-04
Gitansh Anand

Hi, I made a small mistake. In the type input, there is no need to add a dot before the type (look at the image below).
I am adding updated OML; please try once again with some different values for quality that work for you (from my previous experience, 0.95 with jpeg would be just fine).

PDF sender.oml
UserImage.jpg
Ide Fatsha

I have just made the correction.... Its working now. Thank you

2024-12-10 04-40-04
Gitansh Anand
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ide,

Take a look at the Ultimate PDF Forge asset. It can create a PDF from the current screen, which should be what you want.

2024-12-10 04-40-04
Gitansh Anand
Solution

Hi @Ide Fatsha, Look at this component. To use this wrap everting that you want to be a part of your PDF in a container, place the two blocks from the component above that container and pass the container's ID in the main block (the main block is a button). It will return the binary data of the PDF, which you can send as an attachment in your email template.

Thanks
Gitansh Anand

UserImage.jpg
Ide Fatsha

Where can I find the container ID

UserImage.jpg
Ide Fatsha

I was able to able to make the button download a pdf of the screen.. Now I want to send the pdf screen as an email....... Does the file get saved to some sort of database? I want to be able to send the file in an email without have to upload it first.... I want to do that with a button

2024-12-10 04-40-04
Gitansh Anand

Hi, First of all, in the screenshot, I can see you are using the main block twice; you need to replace one with the exec block if you have not done so already.
Now the exce block will have an event called "ReturnBinary, Create a handler for that event, and it will provide you the binary data without any need to upload it anywhere.

UserImage.jpg
Ide Fatsha

i fixed, It seems to be working now.... The button downloads a pdf of the current screen


Now I want to send the pdf screen as an email....... Does the file get saved to some sort of database? I want to be able to send the file in an email without have to upload it first.... I want to do that with a button 

2024-12-10 04-40-04
Gitansh Anand


Hi, Please look at the OML attached, What you need to do is set the inputs of the Exce block as in the below image and add an event handler. You can find the logic of the handler in the OML. 

Test.oml
UserImage.jpg
Ide Fatsha

My block doesn't have the input parameters in your block.... Do I add them on the module for the block? also what data types are they?


2024-12-10 04-40-04
Gitansh Anand

Hi, just remove the options paramter that you have correctly assigned, and then you will find a plus button beside the "Options" (refer to the image below), or you can assign the values to that option variable in the OnInitialize event of the screen.
If you still have any issue, may be you could upload your OML and I will modify it for you.

2024-12-10 04-40-04
Gitansh Anand

From what I can see, the OML you have attached should work fine. Are you getting some sort of error somewhere?

UserImage.jpg
Ide Fatsha

The email part doesn't seem to work at all.... The file would just be downloaded when I click on the  button..... I after I made the changes you suggested... I'm getting the below error when the button is done loading

2024-12-10 04-40-04
Gitansh Anand

Hi, try with this modified OML.
I have changed 2 input values (refer to the below image).

PDF sender.oml
2024-12-10 04-40-04
Gitansh Anand

In case this does not work, try adding a message "Html2Pdf_Js_ExecBlockReturnBinary" so that it can be identified if the problem is in generating the PDF or sending an email (refer to the image below).

UserImage.jpg
Ide Fatsha

It displayed the message before giving the same error message

UserImage.jpg
Ide Fatsha
2024-12-10 04-40-04
Gitansh Anand

It is clear that the component is working fine, the problem is in sending email.
I have a few suggestions.
1. The problem might be that the file size is large and because of that, it is taking a long time to download. For that reason, disable the email call and download the file generated with the new settings, then look at the size of the file. If it is too large, reduce the quality.
2. Trigger the email separately, once without attachment and once with attachment, and look what is happening.
3. Increase the request timeout value.
4. I am not sure if it will solve the issue, but add some UI to the email template.

2024-12-10 04-40-04
Gitansh Anand

The problem is most definitely because of the file size. As I observed on your page, the pdf being generated is 3.7 MB or more, and it may be because of that that you are getting a connection timeout. Please apply the settings I mentioned earlier (set type to ".jpeg" and quality to 0.5; refer to the image and OML shared before) and check again.

UserImage.jpg
Ide Fatsha

i have just downloaded the oml you shared eariler where you made the changes and it gave me the same error it did before ("Connection timed out")

2024-12-10 04-40-04
Gitansh Anand

Hi, I made a small mistake. In the type input, there is no need to add a dot before the type (look at the image below).
I am adding updated OML; please try once again with some different values for quality that work for you (from my previous experience, 0.95 with jpeg would be just fine).

PDF sender.oml
UserImage.jpg
Ide Fatsha

I have just made the correction.... Its working now. Thank you

2024-12-10 04-40-04
Gitansh Anand
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.