Attachment sent via AWS SES not visible on iphone - amazon-web-services

Our service send email with attachment which is not visible on ios devices.
AWS team suggested to add double quotes around file name but when i try to add ", MimeBodyPart turning into escape character.
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setDisposition(Part.ATTACHMENT);
messageBodyPart.setDataHandler(new DataHandler(Base64.getMimeDecoder()
.decode(attachment.getAttachment()), attachment.getContentType()));
messageBodyPart.setFileName("\""+ attachment.getName()+"\"");
From: donotreply#abc.com To: test#abc.com Message-ID:
<962944318.2.1571250351443#[10.200.78.179]> Subject: subject for test
MIME-Version: 1.0 Content-Type: multipart/related;
boundary="----=_Part_1_977674685.1571250351337"
------=_Part_1_977674685.1571250351337 Content-Type: multipart/alternative;
boundary="----=_Part_0_474488818.1571250351334"
------=_Part_0_474488818.1571250351334 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Hi your email send is success
------=_Part_0_474488818.1571250351334--
------=_Part_1_977674685.1571250351337 Content-Type: application/pdf; name="\"myData.pdf\"" Content-Transfer-Encoding:
base64 Content-Disposition: attachment; filename="\"myData.pdf\""
ICAgICAgICAgDXhyZWYNNCAxMQ0wMDAwMDAwMDE2IDAwMDAwIG4NCjAwMDAwMDA2NjAgMDAwMDAg
------=_Part_1_977674685.1571250351337--

Found fix, issue was with respect to content-type. changing content-type to multipart/mixed resolved it.

Related

Sending headers for every part in multipart request

I would like to send specific headers with every part in multipart request. Example below.
POST /api/my_resource
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryFVgKJdNNgzHnHwTz
[Fri Aug 02 10:25:23 CEST 2019]
------WebKitFormBoundaryFVgKJdNNgzHnHwTz
Content-Disposition: form-data; name="field"
My-Custom-Header: value
some data ...
------WebKitFormBoundaryFVgKJdNNgzHnHwTz
Content-Disposition: form-data; name="file"; filename="my_file.txt"
Content-Type: text/plain
My-Custom-Header: value
Lorem ipsum ...
How to do this using postman?
See https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 for the multipart/form-data specs - it does not allow for custom headers.

Creating an ICS file in python sends as a plain text email to external clients

I'm creating an ICS to attach to an email with SMTPLib and Email libraries in python. When I send the meeting request, it shows as a meeting request normally should inside of our organization. When I send the meeting request to people outside of the organization, it shows to those people as just a plain text email with no options to accept, decline, etc.
Pasted below is the output are the email headers being received which includes the icalendar format. Many of the possible solution I've found are that it's an error on the user's end but when I send a meeting request created in outlook and send it to an external email address, it will work fine.
Is my icalendar format incorrect?
Content-Type: multipart/mixed; boundary
MIME-Version: 1.0
Reply-To: test#test.com
Date: Fri, 15 Jun 2018 10:55:17 -0400
Subject: test
From: test <SchedulerApp#test.com>
To: test#test.com,another.test#gmail.com
Content-Type: multipart/alternative; boundary="
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
<h1>Test Email Body</h1>
MIME-Version: 1.0
Content-Type: text/calendar; method="PUBLISH"; charset="us-ascii"
Content-Transfer-Encoding: 7bit
BEGIN:VCALENDAR
PRODID://SchedulerApp//test company//en
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20180616T074500
DTEND:20180616T084500
DTSTAMP:20180615T105517Z
ORGANIZER;CN=SchedulerApp:mailto:test#test.com
UID:FIXMEUID20180615T105517Z
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ- PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE
;CN=test#test.com;X-NUM-GUESTS=0:
mailto:test#test.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ- PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE
;CN=another.test#gmail.com;X-NUM-GUESTS=0:
mailto:another.test#gmail.com
CREATED:20180615T105517Z
<h1>Test Email Body</h1>
SEQUENCE:0
SUMMARY:test
LOCATION:test location
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
For anyone that might be looking at this question, I looked at an ICS file that I saved from an outlook appointment and made that look more like what I was outputting in python. This resolved most of my issues.

Restsharp vs Postman - content-type for a video

For testing one of our API endpoints, I need to upload a video. Our testing framework uses RestSharp.
The call works with Postman, which generates the following relevant headers and body:
Content-Type: multipart/form-data; boundary=--------------------------285414664033564173408812
Accept: */*
content-length: 1055942
----------------------------285414664033564173408812
Content-Disposition: form-data; name=""; filename="uservideo.mp4"
Content-Type: video/mp4
// binary data here
Now, when attempting the same using RestSharp, the request is constructed as follows but it fails:
Accept: application/json
Content-Type: multipart/form-data; boundary=-----------------------------28947758029299
Content-Length: 1055956
-------------------------------28947758029299
Content-Disposition: form-data; name="uservideoTest"; filename="uservideo.mp4"
Content-Type: application/octet-stream
// binary data here
The code used is as follows:
restRequest.AlwaysMultipartFormData = true;
restRequest.AddFile(request.FileName, request.FullPath);
Is it possible to have the RestSharp request constructed like the Postman request?
Found it, the answer is:
restRequest.AlwaysMultipartFormData = true;
restRequest.AddFile(request.FileName, request.FullPath, "video/mp4");

Facebook Graph API: How To Publish Text To Page, Including Image Attachment?

The documentation gives an example of how to upload an image, not via url, but as an attachment:
https://developers.facebook.com/docs/messenger-platform/reference/attachment-upload-api
curl -F "message={'attachment':{'type':'image', 'payload':{'is_reusable':true}}}" -F "filedata=#square.png;type=image/png" "https://graph.facebook.com/v2.12/1843037429354999/photos?access_token=<ACCESS_TOKEN>"
This leads to the following request:
POST https://graph.facebook.com/v2.12/<MY_PAGE_ID>/photos?access_token=<MY_ACCESS_TOKEN> HTTP/1.1
Host: graph.facebook.com
User-Agent: curl/7.52.1
Accept: */*
Content-Length: 2833
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------c71046aadf1a4e33
--------------------------c71046aadf1a4e33
Content-Disposition: form-data; name="message"
{'attachment':{'type':'image', 'payload':{'is_reusable':true}}}
--------------------------c71046aadf1a4e33
Content-Disposition: form-data; name="filedata"; filename="square.png"
Content-Type: image/png
<IMAGE_DATA>
--------------------------c71046aadf1a4e33--
However, this example does not work as advertised. The json object in the message parameter is literally posted as text in the post.
I'd like to be able to send along json post data that includes a 'message' and a 'access_token', so that I don't have to include the access token in the url.
How can I ensure that the type/image/payload json object is applied as a configuration, rather than used as the literal post message?
And how can I send along 'message' and 'access_token' in the postdata?
Found the solution.
This command...
curl -F "access_token=<MY_ACCESS_TOKEN>" -F "message=This is the message I wanna post." -F "filedata=#square.png;type=image/png" "https://graph.facebook.com/v2.12/<MY_PAGE_ID>/photos"
Gives this working request:
POST https://graph.facebook.com/v2.12/<MY_PAGE_ID>/photos HTTP/1.1
Host: graph.facebook.com
User-Agent: curl/7.52.1
Accept: */*
Content-Length: 3077
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------e94f377a15b0500f
--------------------------e94f377a15b0500f
Content-Disposition: form-data; name="access_token"
<MY_ACCESS_TOKEN>
--------------------------e94f377a15b0500f
Content-Disposition: form-data; name="message"
This is the message I wanna post.
--------------------------e94f377a15b0500f
Content-Disposition: form-data; name="filedata"; filename="square.png"
Content-Type: image/png
<IMAGE_DATA>
--------------------------e94f377a15b0500f--
All of a sudden it dawned on me. If the 'message' parameter posts a message, then why not simply put the message I want to post in there. Might as well include 'access_token' then, too. And it worked.
Instead of the deprecated 'message', you can also use 'caption' and it will also work.
Anyway, I can now attempt to reproduce this http request from C#. Glad I found this, because it saves me the effort from having to install the Facebook PHP SDK just to see how such a request should be formed.
(Why is there so little Facebook Graph API C# support, anyway?)
I still have no idea how to properly send along the attachment/type/image/payload json object from Facebook's documentation, though.
Oh, well.

Upload file to Drive and set file name

I want to upload a file to Google Drive and set its name as I understood I have to use uploadType=multipart
I am under c++ and using cURL lib.
How can I proceed?
You need to make a multipart request with metadata and media parts. Use curl_formadd and make sure your request looks like:
POST /upload/drive/v2/files?uploadType=multipart HTTP/1.1
Host: www.googleapis.com
Authorization: your_auth_token
Content-Type: multipart/related; boundary="boundary_tag"
--boundary_tag
Content-Type: application/json; charset=UTF-8
{
"title": "My title"
}
--boundary_tag
Content-Type: image/jpeg
data
--boundary_tag--