Say I made a template in AWS simple email service,
I'm able to send emails just fine (as long as I provide all the necessary fields).
Now I want to add an attachment to the email -> A pdf file of the original email sent.
How would one go about that?
I was hoping Simple Email Service has this functionality built in.
Otherwise, do I need to make a new template that has an attachments field and send the new template ?
I looked here: Sending email with attachment using amazon SES
and it seemed like quite a pain to do..
In addition, I'm using Java but any solution / help in any language will be appreciated!
thanks.
update: the PDF file needs to be regenerated each time with different information.
anyone?
Create a PDF file that you want to attach to your email.
Upload the PDF file to an S3 bucket in your AWS account.
Update your email template to include the attachment by adding the following code snippet to your email template:
{
"Attachments": [
{
"Filename": "filename.pdf",
"Content": {
"S3Reference": {
"Bucket": "your-bucket-name",
"Key": "path/to/filename.pdf",
"ObjectVersion": ""
}
}
}
]
}
In your email sending code, specify the template name and data to be
sent in the email. For example:
const params = {
Destination: {
ToAddresses: ['recipient#example.com']
},
Template: {
TemplateName: 'your-template-name',
TemplateData: JSON.stringify({
"name": "John Doe",
"message": "This is a test message"
})
},
Source: 'sender#example.com'
};
const sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).sendTemplatedEmail(params).promise();
sendPromise.then(function(data) {
console.log(data.MessageId);
}).catch(function(err) {
console.error(err, err.stack);
});
This will send an email using the specified template and include the PDF attachment that was uploaded to your S3 bucket.
Related
I have uploaded some test files to my google drive using their website and my gmail account (x#gmail.com). The files are in "My Drive" and not shared drive. I am then trying to write a google drive java api and oauth authorization code flow based program to transfer the ownership of these files to my another gmail account(y#gmail.com). i.e both the accounts belong to #gmail.com.
I am logged in to my application using x#gmail.com using authorization code workflow and my app is trying to access Google APIs with my access token. I am able to create a new permission on test files to make y#gmail.com a "writer" of the file. But when I try to make "y" an owner, I get error message. This is despite of x being the owner and being the one whose access token is used.
How do I transfer the ownership to another account?
Message changePerms(#PathVariable(name = "fileId") String fileId, #PathVariable(name = "userEmail") String newOwnerEmail) throws Exception {
Drive drive = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, getOauthCredentials())
.setApplicationName("my-app").build();
Permission newOwnerPermission = new Permission();
newOwnerPermission.setEmailAddress(newOwnerEmail);
newOwnerPermission.setType("user");
newOwnerPermission.setRole("owner"); // Works if this is "writer" so my credentials and auth is working
drive.permissions().create(fileId,newOwnerPermission).setTransferOwnership(true).execute();
}
Error :
POST https://www.googleapis.com/drive/v3/files/19wvNc4TmXhODJa7Iy3Qq97UAD8fJrVg/permissions?transferOwnership=true
{
"code": 400,
"errors": [
{
"domain": "global",
"message": "Bad Request. User message: \"You can't change the owner of this item.\"",
"reason": "invalidSharingRequest"
}
],
I think you can't transfer ownership files if they have been uploaded to your Drive. There was a mention of this on the help page, but that one line was removed earlier this year (though I can't say I know why as it appears that nothing has changed).
The current version of the help page is here, but as you can see using the Wayback Machine that only one month ago the following line was still present:
You can only transfer ownership of Google files and folders.
So I would say that this is probably the reason.
I'm using sendgrid java web api client from their website to send mail through the web api gateway. My problem is that i can only send one message per request and i usually have need to send 1000-1500 messages at a time which are all different in content, so I just send them in a loop. However, this makes 1000-1500 api request which is very slow.
Is it possible to send multiple individual different emails in one request?
This is a bit of a workaround, but you could batch different emails together into one request by using the substitution property of the X-SMTPAPI header. In your email body, include only the substitution token, e.g. %content%. Then pass your actual content in the header, e.g.
{
"to": [
"john.doe#gmail.com",
"jane.doe#hotmail.com"
],
"sub": {
"%content%": [
"Here is the content for the email to john.doe",
"And this is some different content for jane.doe"
]
}
}
Yes, it is:
https://sendgrid.com/docs/Integrate/Code_Examples/java.html
You can just keep adding multiple 'tos' to your email, like this:
email.addTo("anemail#example.com")
However, you want to do it via adding multiple BCCs instead so you don't give away everyones email address.
email.addBcc("anemail#example.com")
I'm using Java gcm-server to send messages to Android client apps, and I would like to send a message to a specific topic as showed here.
My problem is that I only managed to send a message using the Sender class, to a list of registration_ids, and I can't figure out how to use parameter "to": "/topics/myTopic" (I read the source code and it seems it is not implemented).
Any advice?
Yes,Right Now... Not Implemented yet,
you need to make a HTTP POST request to :
https://android.googleapis.com/gcm/send
with body
{
"data":
{
"title": "Test Title",
"message": " Your Message"
},
"to" : "/topics/global"
}
For more Help -
https://github.com/googlesamples/google-services/blob/master/android/gcm/gcmsender/src/main/java/gcm/play/android/samples/com/gcmsender/GcmSender.java
When I send request it looks like (Google Chrome Console) :
42/v1/user,["currentPerson",{"transactionId":"53445t-53454-534543-53453435"}]
where 53445t-53454-534543-53453435 - is unique transactionId which I automatically include in request and each response.
The response looks like
42/v1/user,["currentPerson","53445t-53454-534543-53453435",{"id":5,"firstName":"Ivan"}]
where /v1/user - namespace with versioning;
1) I don't want the 42. And don't want array on top-level
2) I just want such kind of response
{
"transactionId": "53445t-53454-534543-53453435",
"namespace": "/v1/user",
"event": "currentPerson",
"person": {
"id": 5,
"firstName": "Ivan"
}
}
3) And such kind of request
{
"transactionId": "53445t-53454-534543-53453435",
"namespace": "/v1/user",
"event": "currentPerson"
}
Now I use socket-io js client but only for test purposes, service will be used with using some C++ library, so I need to use not the socket.io style format.
Is it possible? What methods can I use?
I have found addJsonObjectListener method and sendJsonObject, but they was removed in 1.7.0 and anyway I don't want to pass a #class directive, it seems weird to me to give client a knowledge about server class hierarchy. I just want define some object on the client and parse it manually on the server, then pass manually formed json to the client.
P.S.: By the way Configuration.jsonTypeFieldName is not available now, so #class now is the only option of name.
netty-socket-io 1.7.7
I suppose to convert Json response in String and send it as String.
String json = convertInString(json);
buf = Unpooled.copiedBuffer(json, CharsetUtil.UTF_8);
ctx.write(a);
I am working on developing a REST-API, ie Alfresco based java-backed webscript.
Where I am supposed to pass a Json as POST request parameter field.
When I try to retrieve the parameter field on server side using:
webScriptRequest.getParameter(json);
I am recieving a corrupted Json.
Based on analysis its getting corrupted because of one of the below fields or may be combination of them,
I don't know exactly which special character is causing this corruption problem.
Can anybody help me out in figuring-out this issue.
My hunch is some special character combination in below field is corrupting the json:
2014-04-23T13:42:24.962-04:00
/case/77777777/doc/x-search-found.pdf
http://temp.com/doc/source/url
/case/77777777/doc/my-findings.pdf
2014-04-23T13:42:24.962-04:00
"docGroupNames": ["working", "suggested"]
If I remove above fields, I start receiving the healthy json on server side.
Below is the sample JSON:
{
"documentAlias": "DocNameForTmngUiDisplay",
"modifiedByUserId": "User XYZ",
"sourceSystem": "TMNG",
"sourceMedia": "electronic",
"sourceMedium": "upload",
"accessLevel": "public",
"scanDate": "2014-04-23T13:42:24.962-04:00",
"docList": [
{
"documentId": "/case/77777777/doc/x-search-found.pdf",
"metadata": {
"modifiedByUserId": "User XYZ",
"documentAlias": "nickname",
"sourceMedia": "paper",
"docSourceUrl": "http://test/doc/source/url",
"docCategory": "web"
}
},
{
"documentId": "/case/77777777/doc/my-findings.pdf",
"metadata": {
"sourceMedium": "fax",
"accessLevel": "public",
"scanDate": "2014-04-23T13:42:24.962-04:00",
"evidenceSourceTypeId": "123",
"docGroupNames": [
"working",
"suggested"
]
}
}
]
}
Additional Disclosure:
This looks like REST-Client issue, try changing your Rest Client is one probable solution to json corruption issue.
This issue is happening specifically on SoapUI 5.0.0 Above issue is NOT happening on DHC 0.7.2.2 (Chrome based rest client extension)