Power Automate Flow: Rename a file's attachment with the mail receive time and storing the attchment - power-automate

I am absolutely new to the tool. I have a need to extract attachments from a folder in my inbox. Its a folder that gets daily reports. Those reports do not have the date time mentioned in the attachment name, hence I need to download the attachment after renaming them with the mail received date.
I have searched and none of the solutions are exactly matching my ask. Almost all of them are talking about "When a new mail arrives", whereas I need to parse through each mail that is already in this folder.
I am unable to figure out how to rename the attachment with the received date in a loop.
Formula for the Compose piece:
concat(formatdatetime(triggerBody()?['DateTimeReceived'],'yyyy-MM-dd-hhmm - '),item()?['Name'])
Here is what I have so far:

I assume you want to receiveddatetime property of the email? Within the expression you are referring to a property from the Manually trigger a flow action.
However, the details of this property are in the Get Emails (v3) action. You can refer to the receiveddatetime property by using the items() function instead.
Try this expression:
concat(formatdatetime(items('Apply_to_each_2')?['receivedDateTime'],'yyyy-MM-dd-hhmm - '),item()?['Name'])

Related

Go-Mail multiple recipients and attachment

I am trying to make an email service using go-mail library and made it working. However there are few challenges that i am unable to solve
I have the struct for form data-
type SendMailBody struct {
EmailTo []string `form:"sendTo"`
Subject string `form:"subject"`
Body string `form:"body"`
}
The form data that i am sending to the API is
subject: Notification
sendTo:["abc#gmail.com", "xyz#gmail.com"]
body:You have been notified
Challenges-
If I pass a single email in "sendTO", It is working fine. But after passing the slice of emails, it is unable to send emails to the recepients. How can i make it work?
If I pass the attachment through Form data, how can I attach it with the mail. In documentation, it is mentioned that we can do it like that "m.Attach("/tmp/image.jpg")" . But how should i do it if i pass the attachment via form data in API
Please guide me through that.
Some more details are needed to help here. In particular which go-mail are you using?
For 1.)
If you refer to https://github.com/wneessen/go-mail, using Msg.To() should work fine with multiple recipient. See the documentation at: https://pkg.go.dev/github.com/wneessen/go-mail#Msg.To
If you refer to https://github.com/go-mail/mail, there is Message.SetAddressHeader() (https://pkg.go.dev/github.com/go-mail/mail?utm_source=godoc#Message.SetAddressHeader) which does not support multiple recipient addresses. You would need to use Message.SetHeaders() for the "To"-header instead (https://pkg.go.dev/github.com/go-mail/mail?utm_source=godoc#Message.SetHeaders).
For 2.)
This totally depends on how you read the attachment data (and again also on the go-mail library you are using). https://github.com/wneessen/go-mail has different ways of attaching and embedding files (i. e. from a local file, from embedFS, from an io.Reader...)

how to send email attachments using power automate to webapi

I am new to power automate. I need to read my email attachments and send each attachment to webapi as base64. I used below expression to convert email attachment to base64. but flow shows error as "Correct to include a valid reference to 'Get_Attachment_(V3)' for the input parameter(s) of action 'HTTP'.
what should be correct expression to convert attachment to base64.
expression: base64(body('Get_Attachment_(V3)')?['contentBytes'])
error:
A couple of things.
Firstly, in your JSON body, you just need to put quotes around the value of the content property.
Secondly, make sure you have a Get Attachment (V#) step prior to the HTTP action.
This step actually retrieves the contents of the attachment.

How to read gmail inbox messages and extract the data from the email in a word/excel folder using UiPath?

I'm using gmail account to extract the data, from the body of the mail and I want to store that data in a word/excel folder.
Can someone explain the process to achieve this?
The email body would be like this:
Hello!
First name
John
Last name
Doe
Email
sample#gmail.com
Message
Text
You can read the email using the Get IMAP Mail Message activity and get the Body of Email in a Text then you can use the String manipulation/regex to find the required text and then store it in Excel/Word.
You may need to keep the following things in mind.
You will need to create an App Password by going to your Google Account Settings (https://myaccount.google.com/apppasswords) and use that Password in the Get Mail Message Activity.
To Get the Email Body the EmailMessage.Body property will not work instead you will need to use the EmailMessage.Headers("PlainText") Here EmailMessage is the Each Email Message from the list of Message. Here is the screenshot.
Above If condition is used to check if the Subject of Email which we want to read.
Once you get the Email Body in a String Variable you can use either String Manipulation or Regex to extract the required data from the body of the email and write to the excel or word.
Hope this helps.

PowerAutomate get SOURCE of email body

I need to access the source of an email body through PowerAutomate. Unfortunately the standard HTML to Text - Body solution doesn't work as the emails I want to watch have an embedded link to our ERP (Coupa) and I only get this:
[https://urldefense.com/v3/__http:/www.coupa.com__;!!longstring]
When checking the source of the email body (or actually opening the email), the string I'm looking for is there but Google failed me on how to actually get the source of an email instead of the above conversion.
Full scope: watch inbox for automated emails generated for supplier registration requests, add row to spreadsheet with supplier's name, material group (regex match) and responsible person (xlookup in the table)
Using Compose - Body instead of HTLM to Text gets the source of the email body.

Setting properties while composing an Outlook Mail without forcing TNEF, and referring to those properties after sending

I am having a similar problem to the one described in this previously asked question, but I am looking for a bit more detail in the answer as my lack of experience in this area doesn't allow me to fill in some of the blanks:
Tag Outlook MailItem with ID number before send without causing TNEF (RTF) send
Like the asker of that question, I would like to set a User Property, say it's named "XXXX", to a MailItem while the user is composing it, so that when the user later revisits that same MailItem in his or her Sent Items folder I could read the "XXXX" property's value again.
My additional questions would be as follows:
Dmitry Streblechenko suggests using MailItem.PropertyAccessor.SetProperty, but wherever I see that used I see people using a schema link to represent the property. What would be the correct schema link to use if I want my property still to be known as "XXXX"? In other words, what would be the correct syntax to use in Dmitry's suggestion?
I gather I could use a ".GetProperty" call to read the property later from the Sent Items, but the problem is that our add-in has been around for years, and users sent items are already full of MailItems with the original UserProperty "XXXX" in them. Will I still be able to use UserProperties to get property "XXXX" even if I use .PropertyAccessor.SetProperty to set them?
Alternatively, if I kept using the original code to set UserProperties while composing the message, but I then used .PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8582000B", false) during the ItemSend, like the original poster is suggesting, then I understand the UserProperties are not sent out with the message, which is fine by me, but will they still be available when revisiting the message in the Sent Items folder? Eugene Astafiev suggests that it's safe to use that .SetProperty call, but he doesn't clarify whether it affects what happens to the message at the Sender's end.
My personal preference would be a solution that would a) allow me to send the item without having to force Outlook in any way to send the message in any particular format and b) be able to continue to access the properties in the users' inboxes as we always have through the MailItem's UserProperties, but I am aware that I may be asking for something impossible here.
You need a property in the PS_INTERNET_HEADERS namespace. E.g. http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/x-my-prop.
Yes if you specify the full DASL name.
Yes, the user property will still be there in the Sent Items folder.

Resources