Sunday, July 8, 2012

Email with Attachments via Spring and SendGrid (Part 3)

Review

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


Configuration

Here are the important configuration files that needs to be declared:
  • spring.properties
  • applicationContext.xml
  • spring-servlet.xml
  • web.xml

spring.properties
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.


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


spring-servlet.xml


web.xml


Next

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! Del.icio.us 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

4 comments:

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

    ReplyDelete
    Replies
    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());

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

    ReplyDelete