Sending embedded survey email using MonkeySurvey API - java

What should be the body-text or body-html when doing a POST request using this API to create messages?
API - https://developer.surveymonkey.com/api/v3/#collectors-id-messages
When I am inserting survey link in the body, I am not getting a clickable embedded question in the mail body like we get when using email collector from console.

Building that format is not currently supported in the API, you can only create with a custom HTML.
That said you can copy a previous message that is in the right format through the API. From the link you specified: https://developer.surveymonkey.com/api/v3/#collectors-id-messages
It shows you can set a from collector/message to copy:
POST /v3/collectors/<collector_id>/messages
{
"from_collector_id": "<any_collector_id>",
"from_message_id": "<message_id_from_provided_collector_id>"
}
That will take a copy of a message you already have created as a template and create a new message. Hopefully that could be a good workaround for your use case.

Related

Why am I not able to read the complete email body using Exchange Web Service Java API?

I am using EWS Java API to read and process emails. One such email contains few conversation and a MS Teams meeting information at the end. While reading such an email, the EmailMessage.getBody() returns only the MS Teams meeting information and all the other contents of the email body are ommitted. Sample code below:
EmailMessage message = EmailMessage.bind(service, new ItemId(item.get(nMessagePos).getId().getUniqueId()));
String emailBody = message.getBody().toString()
I tried setting the BodyType property to both HTML and Text and then fetched the body of the email but it still returns only the Meeting invite details.
Is there any specific reason for this and is there a way for me to get the complete email body?
I would try to enable tracing https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-trace-requests-responses-to-troubleshoot-ews-managed-api-applications or look at the actually soap responses your getting it could be a parsing issue at the client side (eg bug in the library). You could also try getting the Mimecontent of the Message instead and then parse back the body from that content. Something like EWSEditor might be useful for trying to diagnose what is going on it will show you what the responses look like and allow you to test mimecontent etc without needing to write any code https://github.com/dseph/EwsEditor/releases.

In gmail api get message, how do prevent getting the previous message chain when getting current message? [duplicate]

I'm using the Gmail RESTful API directly (not from some library).
Looking at the documentation here Gmail Documentation.
I have managed to get the content of the message body, however it also returns the whole history chain for the current message.
Is there a way to get a response from the API only the requested message body, without the whole thread history?
According to this thread, it is not possible because it is part of the email's body content and you're specifying the ID of the message to retrieve.
You are getting the full reply message. When the report replied, they quoted the original message and this the text of the original is in the reply message. You may just want to do what Gmail and many other modern emails apps do and collapse/hide any reply text which begins with >.
References:
How to get the reply message without the original message from the Gmail API
GMAIL API : How to get the reply without the original message
Most efficient way to get new messages

How to send attachment using AWS SeS raw message and java

I have seen previous question but they make use of java mail api along with aws,but I need implementation solely using rawmessage. Following code I have written so far.It send the mail and create file without data being populated .Any help is appreciated.
I don't know how to attach file in general,example provided by aws doc,they simply write in file rather than attaching from file provided as parameter.
AWS doc link http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/simpleemail/AmazonSimpleEmailService.html#sendEmail-com.amazonaws.services.simpleemail.model.SendEmailRequest-
String data="From: "+from+"\r\nTo: "+to+"\r\nSubject:"+subject+"\r\nMIME-Version: 1.0\r\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\r\n\r\n--NextPart\r\nContent-Type: text/html\r\n\r\n"+message+"\r\n\r\n--NextPart\r\nContent-Type: "+Files.probeContentType(Paths.get(res1.getPath()))+";\nContent-Disposition: attachment; filename=\"attachment.xlsx\"\n\n"+new String(Files.readAllBytes(Paths.get(res1.getPath())))+"\n\n--NextPart--";
SendRawEmailRequest request = new SendRawEmailRequest().withRawMessage(new RawMessage().withData(ByteBuffer.wrap(data.getBytes())));

How to get SMTP-ID in sendgrid API through json?

How to get SMTP-ID in sendgrid API through json? Example :
In the API tutorial they have mentioned to execute
http(s)://username:password#domain/foo.php
and the result will be (in json):
"email": "john.doe#sendgrid.com",
"timestamp": 1337197600,
"smtp-id": "<4FB4041F.6080505#sendgrid.com>",
"event": "processed"
But actually we need the perfect url to get json.
for eg :
https://sendgrid.com/api/bounces.get.json
for bounce mails
similarly , is there anything to get the above sample json.
Thanks in advance..
If you send an Email to SendGrid through the Web API, you won't have an SMTP-ID. That will be generated by the SendGrid server that translates the API call to an SMTP object. So you're right, the SMTP-ID that comes back in the Event POST isn't helpful.
However, you can add Unique Args to your API call using the x-smtpapi argument in the mail.send call. This will let you define whatever tracking metric(s) you want to the message, and it will all come back on the Event POST.
If you are going to use Unique Args feature, please do remember that they will appear in the most Event notifications but not all of them. Please refer for the details to the sendgrid forum topics which include "missing unique_args" and similar. So, think twice before "building the entire infrastructure" around this feature like some of us did :(
I got my answer .
Actually we can try event API using a callback url, that receives POST request having every details about the email delivered, bounced in json format. Whenever some event is triggered we get a request from Sendgrid. Thats cool.
We can keep these details for further Filtering.
Anyway , thanks jacobmovingfwd

Send email via outlook with mail merge using Java

I have a set of contacts in my database. I want my application to build a custom email template for my clients.
My client can set a custom placeholders such as company name, address:
For example:
Dear <<name>>,
This is to inform you that our <<company name>>, located in <<address>> ...
Sincerely,
<<sender>>
After the template is setup I can then use this as a body to my email. Recipients are then fetched from the database.
I am aware of the java.awt.Desktop package which allows me to create a MAIL URI and open it using the user's default email client. The problem is how can I incorporate the mail merge into it? Can you please guide me on existing libraries or solutions to this?
Use the JavaMail library for sending mails. You will find plenty of examples if you search for "JavaMail example", among others: Sending email via Gmail SMTP example. Regarding the placeholders I would simply use the String.replace function.
You will need to control how the variables in the template are setup. I dont think you can parse an arbitrary string and find out if there are variables in it. Hence when a user is adding a variable, make sure that you insert a variable that your program will understand into the email body. Thats a no brainer but thought I'll add it for completeness.
You could save the email body as a velocity template, making sure the variables you added our velocity templating language compliant. Velocity would be easier than string.replace() if there are complicated templates that are being set up. If its a simple one then String.replace() would do.
http://velocity.apache.org/
Next use the java mail library to send it directly from your java program, or launch the default email client of the box using the Desktop class.
EDIT:
If you would like to open outlook then you will need to use Desktop.mail() API. You can pre-populate the to,cc, bcc, subject and body fields in the outlook send email window by constructing an appropriate URI and passing it to Desktop.mail()
mailto:duke#sun.com?SUBJECT=Happy New Year!&BODY=Happy New Year, Duke!
Have a look here for more info:
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/
For multiple recipients, separating the email addresses with commas should work. If that doesn't, try with a semi colon. Outlook uses semicolon..

Categories