cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jimbobcook1
Resolver I
Resolver I

Adding multiple PDF's into Office365Outlook.SendEmailv2

Afternoon,

 

I'm looking at setting 2 screens on my app to be exported as PDF using the new experimental feature within PowerApps, on my screens I have the following to collect the PDF

 

ClearCollect(colpdfview,PDF(
                    scrPDFView,
                    {
                        Orientation: PaperOrientation.Landscape,
                        Size: PaperSize.A4,
                        DPI: 96,
                        ExpandContainers: false,
                        Margin:"1mm"
                    }
                ));Navigate(scrPDFViewResults)

 

This I assume grabs everything I need for the PDF apart from the name of the file which isn't important what it's called, I then move to the 2nd screen and Collect the same information for that screen into the same collection.

 

Now my issue is adding this info into an email as 2 attachments, I realise that I may be going about this the wrong way but as PDF stuff is still quite new to me and PowerApps I thought I'd ask.

 

I can do a single PDF into an email no problem using the following

 

Office365Outlook.SendEmailV2(
    "myemail@email.com",
    "Your pdf Subject",
    "Your PDF is attached",
    {
        From: User().Email,
        Attachments: Table(
            {
                ContentBytes: PDF(
                    scrPDFView,
                    {
                        Orientation: PaperOrientation.Landscape,
                        Size: PaperSize.A4,
                        DPI: 96,
                        ExpandContainers: false
                    }
                ),
                Name: "Export.pdf"
            }
        )
    }
)

 

Any help getting 2 PDF's using a method like above would be great, I'd like to stay away from Power Automate if possible and keep it within the app.

 

Thanks in advance

 

Simon

1 ACCEPTED SOLUTION

Accepted Solutions

Your idea but slightly modified and it seems to work so thank you!

 

On screen 1 (scrPDFView) I put this in to copy the screen (I used an icon already on the screen to set off a timer so I didn't have a random PDF button, also didn't use containers as I was using the whole screen for data), I then navigate to the next screen 

Set(gloTestvar,
    PDF(
                    scrPDFView,
                    {
                        Orientation: PaperOrientation.Landscape,
                        Size: PaperSize.A4,
                        DPI: 96,
                        ExpandContainers: false,
                        Margin:"1mm"
                    }
                ))

Then on screen 2 (scrPDFViewResults) I have another timer that runs off an icon (this makes sure the gallery has refreshed by the time it takes all the info for the PDF), at the end of the timer I use this

Office365Outlook.SendEmailV2("sendingtoemail",
    "Enter email subject here",
    "Enter email body here,
    {
        From: User().Email,
        Attachments: Table(
            {
                ContentBytes: PDF(
                    scrPDFViewResults,
                    {
                        Orientation: PaperOrientation.Landscape,
                        Size: PaperSize.A4,
                        DPI: 96,
                        ExpandContainers: false,
                        Margin:"1mm"
                    }
                ),
                Name: "Export1.pdf"
            },
            
        {
                ContentBytes:gloTestvar,
                Name: "Export2.pdf"
            }
        )
     
})

This seems to add both PDF's into the email which makes me very happy.

View solution in original post

5 REPLIES 5
KeithAtherton
Responsive Resident
Responsive Resident

Hi @jimbobcook1,

 

Try building up several records of PDFs for the Attachments field, similar to the following:

Attachments: Table(
	{
		ContentBytes: PDF(
			scrPDFView1,
			{
				Orientation: PaperOrientation.Landscape,
				Size: PaperSize.A4,
				DPI: 96,
				ExpandContainers: false
			}
		),
		Name: "Export 1.pdf"
	},
	{
		ContentBytes: PDF(
			scrPDFView2,
			{
				Orientation: PaperOrientation.Landscape,
				Size: PaperSize.A4,
				DPI: 96,
				ExpandContainers: false
			}
		),
		Name: "Export 2.pdf"
	}

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Unfortunately the PDF function has to be run on the page and not remotely on another so I couldn't use the screen function but maybe I could put them into a global variable instead, having the collection I though would of been a winner but it seems like it needs a change of code that I'm not familiar with.

 

I shall try and put the first screen in a variable then do it normally for the 2nd.

 

Cheers

 

Simon

KeithAtherton
Responsive Resident
Responsive Resident

Ah, I understand. Good idea about using global variables!


If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Your idea but slightly modified and it seems to work so thank you!

 

On screen 1 (scrPDFView) I put this in to copy the screen (I used an icon already on the screen to set off a timer so I didn't have a random PDF button, also didn't use containers as I was using the whole screen for data), I then navigate to the next screen 

Set(gloTestvar,
    PDF(
                    scrPDFView,
                    {
                        Orientation: PaperOrientation.Landscape,
                        Size: PaperSize.A4,
                        DPI: 96,
                        ExpandContainers: false,
                        Margin:"1mm"
                    }
                ))

Then on screen 2 (scrPDFViewResults) I have another timer that runs off an icon (this makes sure the gallery has refreshed by the time it takes all the info for the PDF), at the end of the timer I use this

Office365Outlook.SendEmailV2("sendingtoemail",
    "Enter email subject here",
    "Enter email body here,
    {
        From: User().Email,
        Attachments: Table(
            {
                ContentBytes: PDF(
                    scrPDFViewResults,
                    {
                        Orientation: PaperOrientation.Landscape,
                        Size: PaperSize.A4,
                        DPI: 96,
                        ExpandContainers: false,
                        Margin:"1mm"
                    }
                ),
                Name: "Export1.pdf"
            },
            
        {
                ContentBytes:gloTestvar,
                Name: "Export2.pdf"
            }
        )
     
})

This seems to add both PDF's into the email which makes me very happy.

KeithAtherton
Responsive Resident
Responsive Resident

My pleasure @jimbobcook1. Thanks for the update, your solution looks good, glad it's working!


If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,703)