Transmission api setting wrong To header when specify header_to with multiple recipients - go

I'm trying to send an email to multiple people(multiple to addresses) and have them all listed in the email clients like a regular email. When I set the header_to field on all recipients to email1#foo.com, email2#foo.com I end up with emails that have a to header set to "First Name" <email1#foo.com, email2#foo.com> which is incorrect.
This shows up as a single person with multiple email addresses in most clients and the header is wrong.
Why is the sparkpost transmission api messing with the header_to field? It's docs say that it uses this in place of generating a To header for you.

After going through every page of docs I could find to try and figure out how sparkpost's backend works I've found that you must omit the Name field on all recipients.
https://developers.sparkpost.com/api/recipient-lists/#header-recipient-object

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 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.

Microsoft graph API - empty bccRecipients list

This is the Scenario:
In the same Azure tenant, I used one account (user_1_address) to send emails to the other account (user_2_address) using outlook (o365).
I sent 3 emails, one where user_2_address is BCCed, one CCed, and one when it's the TO recipient.
I'm using Microsoft graph API to get a list of emails received by user_2_address in a specific time range, using this query:
https://graph.microsoft.com/v1.0/users/{<user_2_id>}/messages?$filter=
receivedDateTime ge <some date> and receivedDateTime lt <some other date>
and isDraft eq false
and sender/emailAddress/address ne '<user_2_address>'
I'm getting all the three emails user_2_address had received from user_1_address. But in the email user_2 was BCCed the bccRecipients list is empty, when it should contain user_2_address :(
I have seen this question about sending an email from Gmail and BCC an outlook user:
Microsoft graph API: empty BCC field
In that case, also the bccRecipients list was empty, but it was resolved by saying the BCC is removed when sending the emails from an external source (Gmail in that case). When for me it's not an external source - both users are using outlook in the same tenant.
So my questions are:
Is it the desired behaviour, or is it a bug?
Now, let's say I'm using the query above where I get all emails where the sender is not the user_2_address and it's not a draft. Can I assume that every email I get where user_2_address is not in the ccRecipients and toRecipients lists - that email was BCCed to user_2_address?
Thanks!
The bcc field in a Message is an envelope (P1) recipient only so you should always expect that it will be blank (no matter the context inside a tenant really make no difference). Like the other post referenced if it wasn't blank it would break the RFC and the purpose of a BCC, the only exception is the sent item (which is just a copy of the sent message)
No there are many scenarios that would break that particular logic eg forwarded email is one the comes to mind. You could certainly refine you result set that way, one thing you might want to examine is the X-MS-Exchange-Organization-Recipient-P2-Type: mail header that should get set in your internal to internal scenario (you need to look at the PidTagTransportMessageHeaders extended property to see it)

Filter Microsoft Graph List Messages API to only received messages

Goal: I'd like to be able to filter the "List Messages" API to only return emails that are sent to the user rather than any messages that exist anywhere (such as ones sent out by the user).
Right now, if you query this particular API, you get a list of all of the messages in all folders (including Deleted Items and Clutter folders).
I know that I can filter on isDraft eq false to remove the drafts - but I don't know if there's any filter to say don't include messages sent by the user.
What I've Tried: I've looked over the examples and didn't see anything about filtering like this. I've also taken a look at the OData Query Params and dug into the filter param. The problem is I'm not quite sure what I could even filter on. I do see that there is a sender parameter - but given I've connected via OAuth and haven't asked users to provide their email address I'm not sure I have an easy way to filter on that.
Theoretically, I could first do a request to the https://graph.microsoft.com/beta/me/ endpoint to get the userPrincipalName and then add a filter on from/emailAddress/address ne '<userPrincipalName>' when I call the /me/messages endpoint - but that's going to double the number of API calls I'd need to make. Is that the only option I have or is there a better way to go about this?
Thanks for your time :)
There is no filter parameter that will achieve this directly. If you want to filter away sent messages - you'll need to either decode the base64 encoded JWT access token and extract the userPrincipalName or make a call to the /me endpoint and retrieve the userPrincipalName from that. Once you have that, you can add a filter of from/emailAddress/address ne '<userPrincipalName>'.
Please note that if you are filtering on many things and you have an "order by" param that you'll need to include that param in your filter or you'll receive an error about too many filters.

Getting all email from the Outlook Email Rest API, but spam

I'm trying to get all the emails from a user from the Outlook Email Rest API.
looks like the API only allows to retrieve 50 emails max : no way to retrieve more ?
I need "ALL" emails (not only the one in the inbox). But if we parse all emails, we have a problem : indeed, it includes emails that are in the Spam folder, and there is no "tag" on these emails in the API that show they are spam. We found 2 workarounds :
first scanning all the spam emails, save the ids, then ignore them when we scan for all emails
check the spam folder id, and check that the parentId of the emails is not the spam folder id. It breaks if your contacts are in a subfolder of the spam folder, but who creates folder in spams, right ?
any way to get on an email a flag that it's spam ? There are other flags, like IsRead / IsDraft, but not this one
Thanks a lot
looks like the API only allows to retrieve 50 emails max : no way to retrieve more ?
Yes you can get more. You need to use paging to get the next set of results. There should be an #odata.nextLink property in the response that you can do a GET on to get the next page.
I need "ALL" emails (not only the one in the inbox). But if we parse all emails, we have a problem : indeed, it includes emails that are in the Spam folder, and there is no "tag" on these emails in the API that show they are spam.
Yes this is correct. I think I would do the second option here, match the ID of the Junk folder with the ParentId of the messages.

Resources