sendgrid / sendgrid-java

The Official Twilio SendGrid Led, Community Driven Java API Library

Home Page:https://sendgrid.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Email Activity API: How to retrieve contents of a specific email?

icarrara opened this issue · comments

I need to retrieve contents of a specific message, as for example sender email, target email, Subject, etc.

I used the below code:

SendGrid sg = new SendGrid("SG.xxxxxxxxxxxx");
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("messages");
request.addQueryParam("query", "msg_id="'O7MUu2GaQKODKy_Y2j0r4w.filterdrecv-p3las1-c477c4585-dg6pk-20-6032B583-20.0'");
request.addQueryParam("limit", "1");

sg.api(request);

I receive the below contents:

statusCode:200

body:{"messages":[]}

How I can retrieve original contents of the message as for example from email address, to email address, subject etc?

Thank you in advance for any help.

Ivano

I just found that my API call is correct and in fact after almost a minute I'm able to retrieve the message I was looking for.

There are a few seconds between the new message sent and the availability of it in Email Activity.
There is some chance to cut this intermediate time?

Thank you for any suggest.

Ivano

@icarrara It's not clear to me whether there is a delay in sending and receiving the email itself or just retrieving it using the email activity API. Either way, I would recommend you reach out to support for assistance as this doesn't look like a helper library issue.

@shwetha-manvinkurke There are many minutes or hours after the message is delivered until you can get it from the Email Activity API. It is by design. So I'll close this issue. Thank you for your comment.