title: How to initialize Email without hardcoding using sendgrid with java
body: <p>How can I initialize email in my service class without hardcoding(eg : <code>Email to = new Email("1234@gmail.com")</code>. I use the following code to initialize my email but it returns some error. Help me to fix this. I'm using SendGrid API. Here is my service code:</p>
  
  <pre><code>Email to = new Email();
  
  to.setEmail(emailIDTO.getTO());  //emailIDTO is an object of IDTO class
  // IDTO class takes the value from the JSON request body and initializes it to the email object  
  </code></pre>
  
  <p>And the relevant IDTO snippet:</p>
  
  <pre><code>public Email getTo(){ 
      return to; 
  } // method getTo return the mail id of the recipient. 
  
  public Email createTo(EmailIDTO emailIDTO){ 
     to.setName(emailIDTO.getName(); 
     to.setEmail(emailIDTO.getEmail()); 
     return null; 
  }
  </code></pre>
  
  <p>Error : </p>
  
  <p><code>setEmail (java.lang.String) in Email cannot be applied to (com.sendgrid.Email)</code>
   </p>