Coder Social home page Coder Social logo

android-sendgrid's Issues

Unable to attach image

  • I want to attach an image and I have converted it into Uri, but it's not working.
  • File attachment is working, but Uri attachment is not working.

Getting response code 0

I'm getting response code 0 and Error parsing error message: Value Unable of type java.lang.String cannot be converted to JSONObject. It was working perfectly before. Here is my code

                            SendGrid sendGrid = SendGrid.create(dao.getConfiguration(ThermalogConstants.CONFIG_API_KEY));
                            SendGridMail mail = new SendGridMail();

                            mail.addRecipient("[email protected]", "name");
                            mail.setFrom("[email protected]", "name");
                            mail.setSubject("Alert Warning");

                            String title = "Alert Warning ";
                            SpannableStringBuilder strBold = new SpannableStringBuilder(title);
                            strBold.setSpan(new StyleSpan(Typeface.BOLD),
                                    0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

                            mail.setContent("ok");


                            try {
                                SendTask task = new SendTask(sendGrid, mail);
                                SendGridResponse response = task.execute().get();
                                Log.d("Response", "run: "+response.getCode());
                                Log.d("Response", "run: "+response.getErrorMessage());
                            } catch (Exception e) {
                                Log.d(TAG, "sendEmail: " + e);
                                Log.d("Response", "error: "+e.toString());
                            }
                        }

Did U See this ?

Hi, I tried the workaround, It worked this time.

But I am getting mail in basic text format (NOT HTML) Like this
image

But My Template is similar to this
image

Soruce

        SendGridMail mail = new SendGridMail();
        mail.addRecipient(email, name);
        mail.setFrom("[email protected]", "Rent House Manager Pro");
        mail.setSubject("Welcome to Rent House Manager Pro");
        mail.setContent("");                                       //Tried this one too mail.setContent(" ");
        mail.setTemplateId("API_KEY");
    // JSONObject structured into key/value pairs
        final JSONObject templateData = new JSONObject();
        try {
            templateData.put("first_name", "Hitesh Verma");
            mail.setDynamicTemplateData(templateData);
        } catch (JSONException e) {
            e.printStackTrace();
            Log.d("HIT_TAG", "Err : " + e.getMessage());
        }

 SendTask task = new SendTask(sendGrid, mail);
        try {
            SendGridResponse response = task.execute().get();
            toastHelper.toastInfoMsg("Code " + response.getCode()); //this is 202
            Log.d("HIT_TAG", "SendGrid : " + response.getErrorMessage()); //This is now null
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

Am I Doing Something Wrong?

Originally posted by @itshiteshverma in #10 (comment)

returning response code 400

mail.setDynamicTemplateData(@NonNull JSONObject jsonObject)

// JSONObject structured into key/value pairs
final JSONObject templateData = new JSONObject();
templateData.put("forename", "Jane");
templateData.put("surname", "Doe");
templateData.put("message", "Hello, This is my email");

mail.setDynamicTemplateData(templateData)

This returning response code 400

setReplyTo actually set from address

There is a bug in SendGridMail that prevents the replyTo functionality working.

public void setReplyTo(@nonnull String email, @nullable String name) {
if (name == null)
name = EMPTY;
from.put(email, name);
}

The last line should be replyTo.put

Context doesn't show in the email

I tried to send a email with this code:
SendGridMail sendGridMail = new SendGridMail();
sendGridMail.addRecipient("[email protected]", "myName");
sendGridMail.setFrom("[email protected]", "myName");
sendGridMail.setSubject("Subjet");
sendGridMail.setContent("MyMessage");

But it didn't show "MyMessage" in that email!
Am i doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.