WSO2 email connector - Issue with sending attachments - email

I'm working on an email connector that is sending emails successfully.
But I want to send emails with an attachment.
I am using email connector 1.0.2 that support the attachments in its payload.
<email.send configKey="EMAIL_CONNECTION_SMTP">
<from>{json-eval($.from)}</from>
<to>{json-eval($.to)}</to>
<subject>{json-eval($.subject)}</subject>
<content>{$ctx:DecodedBodyTemplate}</content>
<contentType>{$ctx:contentType}</contentType>
<attachments>{json-eval($.attachments)}</attachments>
</email.send>
And the payload has:
"attachments": [
{
"name": "sampleimagefile.txt",
"content": "This is a text file"
}
]
I tried using base64encoded string in content too.
Yet I'm still receiving emails without any attachment.

I also use email connector 1.0.2 and I don't have any issue sending attachments.
Look here for more info.
So, your payload should look like this:
{
"from": "user1#gmail.com",
"to": "user2#gmail.com",
"subject": "This is the subject",
"content": "This is the body",
"contentType": "text/plain",
"attachments": [
{
"name": "sampleimagefile.png",
"content": "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
}
]
}

Related

Sending emails with SendGrid from a logic app to multiple recipients

Is there a simple way to send emails from an Azure logic app using SendGrid to multiple recipients, e.g. comma-separated etc?
This is how it looks now:
"actions": {
"Send_email_(V3)": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['sendgrid']['connectionId']"
}
},
"method": "post",
"body": {
"from": "webserver#hotmail.com",
"to": "firstaddress#somemail.com",
"subject": "** My subject **",
"text": "Some text",
"ishtml": ""
},
"path": "/v3/mail/send"
},
Is it possible to have
"to": "firstaddress#somemail.com, secondaddress#somemail.com"
?
The SendGrid V3 connector documentation states that you can separate the email addresses by comma in the To, CC or BCC fields:
Valid email addresses separated by a semicolon or comma
Checkout the documentation: SendGrid Connector

Recipient detail in SendGrid Dynamic Template

I need to send a payload to multiple recipients in SendGrid. I use the Dynamic Templates to construct the email body, and all is working fine.
I would like to add a 'Hi {{recipientName}}' line to the email but I cannot find any documentation on it, is it possible?
I cannot include the recipient detail in the payload as a single payload goes out to many recipients
Use personalizations.
Personalizations allow you to override these various metadata for each email in an API request.
Your request will look like this:
{
"from": "gilbert#techmail.com",
"template_id": "YOUR TEMPLATE ID",
"personalizations": [
{
"to": [
{
"email": "john#example.com"
}
],
"substitutions": {
"%fname%": "John",
"%CustomerID%": "C001"
},
},
{
"to": [
{
"email": "peter#example.com"
}
],
"substitutions": {
"%fname%": "Peter",
"%CustomerID%": "C005"
},
"send_at": 1629723541
}
]
}
and it will go as a single request.
Also look at this github comment.

Custom_args not working in sendgrid V3 API but unique_args sends email but not in event_callback

I have used sendgrid v3 api for sending emails. As mentioned in documentation of V3 API I use custom_args to get my params in event callback but it shows 400 bad request, while I use unique_args, the email was sent but the event callback does not send my unique_args params.
data = {"content": [{"value": "dfafds", "type": "text/plain"}], "attachments": [{"content": "UEsDBB......QACAgIAAA=", "type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "content_id": "BqzZqz7LaqO9", "filename": "Contactmanager-company.xlsx", "disposition": "attachment"}], "from": {"email": "bishnusyangja#gmail.com"}, "personalizations": [{"to": [{"email": "bishnu#janakitech.com"}], "custom_args": {"email_msg_id": 106}, "subject": "daff"}]}
Event callback response from send grid is
[{"sg_event_id": "aoDNXRAeRuaCAVRiutD-fg",
"sg_message_id": "epJqlw1JThGw--dDTC1oCQ.filter0099p3las1-8681-5B853F95-29.0",
"smtp-id": "epJqlw1JThGw--dDTC1oCQ#ismtpd0006p1maa1.sendgrid.net",
"timestamp": 1535459222,
"email": "bishnu#janakitech.com",
"event": "processed"}]
I need may custom_args in event callback reponse, In this response I need email_msg_id What is missing here ?
In custom_args, data_type must be string. I fixed it using string data as
"custom_args": {'email_msg_id': '106'}.
While sending mail through java we need to send a unique id from my
side so that when webhook sends me the response I need to check the
status of that mail by its unique id. here is my code in java...
MimeMessage message = (MimeMessage) getNewMessageInstance();
message.addHeader("unique_args", jsonRandomEmailStatisticsId);
And value of jsonRandomEmailStatisticsId is like
{"unique_args":{"randomMessageId":"randomMessageId-308099455"}}
here I got a webhook response from SendGrid
[{
"category": [],
"email": "email#example.com",
"event": "processed",
"marketing_campaign_id": 12345,
"marketing_campaign_name": "campaign name",
"post_type": "event",
"sg_event_id": "sendgrid_internal_event_id",
"sg_message_id": "sendgrid_internal_message_id",
"sg_user_id": 12345,
"smtp-id": "",
"timestamp": 1442349428
}]
But SendGrid does not return random message id values in return of
object response

sending push notification to Iphone using FCM

I am trying to send push notification to iPhone using FCM but notification is not received on my phone. Is there any issue in request json? please help me.
my request json is
{ "notification":{"aps": {"alert": "Hello","badge": 1,"sound ": "default "},"pushtype": "", "message": "Hello"} ,"to" : "c6IJyzv8LiY:APA91bHE1g-51dWnh_ofus0nUfVGwWQBV8zOp5fn9VcQe5GLL6gqLUCQQv1RUnYvQ0MP7Q5bKwgG1_8Uuudf67HV4hU1N-3U4u4uRVpdXw3QrivE8ONxjAAfcbn5cIUzu3B6FbHR8EkG"}
and my response json is:
{\"multicast_id\":5810493506209108338,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1473238399084785%fc69f82ff9fd7ecd\"}]}
I have fixed my problem, correct request json is:
{
"notification ": {
"title": "some title",
"text": "some text"
},
"to": "XjV2kOqh1yXNkJsQop17RlwSwT4jZpuAu-...",
"priority": "high"
}

Mandrill sending to multiple people as separate message via the REST API

I'm trying to send out mails using mandrill. The problem is that when I add multiple recipients to the 'to' parameter, it sends out the same mail multiple times with ALL the recepients in the 'to' list. I was expecting the same mail to be sent out individually to every person in the to list. Am I missing something ?
{
"key": "app-key",
"template_name": "platform-invite",
"template_content": [
{
"name": "connection",
"content": "<a class=\"mcnButton \" title=\"Lets Go\" href=\"http://someurl\" target=\"_blank\" style=\"font-weight: normal;letter-spacing: normal;line-height: 100%;text-align: center;text-decoration: none;color: #FFFFFF;\">Lets go</a>"
},
{
"name": "mailbody",
"content": "<p>Hi </p>\n<p>I would like you to be a ... Tic tic tic...</p>"
}
],
"message": {
"subject": "My subject line over herer",
"from_email": "superman#mydomain.co",
"to": [
{
"email": "person1#gmail.com,
"type": "to"
},
{
"email": "person2#gmail.com",
"type": "to"
},
{
"email": "person3#gmail.com",
"type": "to"
},
{
"email": "person4#gmail.com",
"type": "to"
}
],
"merge_vars": {}
},
"async": false,
"ip_pool": "Main Pool"
}
There's an option in your Sending Options to expose recipients to one another. You can uncheck that box to not show everyone's information in the 'to' header. The option(s) you select in the Sending Options are used by default for your account. You can override any of these options in individual API calls. In this case, you could use the preserve_recipients parameter to override the current default that's set for your account.