Sunday, July 8, 2012

Email with Attachments via Spring and SendGrid (Part 3)


In the previous section, we have discussed and implemented the Java classes. In this section, we will start writing the configuration files.


Here are the important configuration files that needs to be declared:
  • applicationContext.xml
  • spring-servlet.xml
  • web.xml
This contains your SendGrid user and key credentials to access the Web API. This is equivalent to your SendGrid's username and password. This file also contains a temporary directory location for saving file uploads.

In order for file uploads to work, make sure to declare a MultipartResolver bean




We have just completed declaring the required configuration files. In the next section, we will write the HTML form and demonstrate how to use jQuery-File-Upload for uploading files via jQuery. Click here to proceed.
StumpleUpon DiggIt! Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google I'm reading: Email with Attachments via Spring and SendGrid (Part 3) ~ Twitter FaceBook

Subscribe by reader Subscribe by email Share


  1. can you provide send emails with spring and hibernate example

    1. This is really quite simple to do. Unfortunately I don't have time this weekend to provide you an actual example. In this tutorial, all you need to do is provide a DAO or Repository in the EmailService implementation and use Hibernate as your vendor.

      Now, let's say you have a table that's been mapped to a Hibernate-managed entity. I assume you now the basic of Hibernate and CRUD.

      To provide your custom message in the email, just update the following line:
      vars.add(SendGridParameter.TEXT, "");

      For example (this is just a sample!)
      vars.add(SendGridParameter.TEXT, hibernateDao.getEntity.getTextMessage())

      Let's say you have a custom sender, then update the following line as well:
      vars.add(SendGridParameter.SENDER_EMAIL, message.getSenderEmail());

      For example:
      vars.add(SendGridParameter.SENDER_EMAIL, hibernateDao.getEntity.getClientEmail());

  2. 400 Bad Request !! :( am stuck help !!!!!

  3. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    core java training in Electronic City

    Hibernate Training in electronic city

    spring training in electronic city

    java j2ee training in electronic city