/// <summary>
      /// Add new email. Add new email.
      /// </summary>
      /// <param name="name"></param>
      /// <param name="storage"></param>
      /// <param name="folder"></param>
      /// <param name="body"></param>
      /// <returns></returns>
      public EmailDocumentResponse PutCreateNewEmail (string name, string storage, string folder, EmailDocument body) {
        // create path and map variables
        var ResourcePath = "/email/{name}/?appSid={appSid}&amp;storage={storage}&amp;folder={folder}".Replace("{format}","json");
		ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

        // query params
        var queryParams = new Dictionary<String, String>();
        var headerParams = new Dictionary<String, String>();
        var formParams = new Dictionary<String, object>();

        // verify required params are set
        if (name == null || body == null ) {
           throw new ApiException(400, "missing required params");
        }
        if (name == null){
		  ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
		}else{
		  ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name)); 
		}
        if (storage == null){
		  ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
		}else{
		  ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage)); 
		}
        if (folder == null){
		  ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
		}else{
		  ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder)); 
		}
        try {
          if (typeof(EmailDocumentResponse) == typeof(ResponseMessage)) {
            var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
            return (EmailDocumentResponse) ApiInvoker.deserialize(response, typeof(EmailDocumentResponse));
          } else {
            var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, body, headerParams, formParams);
            if(response != null){
               return (EmailDocumentResponse) ApiInvoker.deserialize(response, typeof(EmailDocumentResponse));
            }
            else {
              return null;
            }
          }
        } catch (ApiException ex) {
          if(ex.ErrorCode == 404) {
          	return null;
          }
          else {
            throw ex;
          }
        }
      }
        public void TestPutCreateNewEmail()
        {
            EmailApi target = new EmailApi(APIKEY, APPSID, BASEPATH);
            StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH);

            string name = "email_test.eml";
            string storage = null;
            string folder = null;
            
            EmailDocument body = new EmailDocument();

            EmailProperties emailProperties = new EmailProperties();

            System.Collections.Generic.List<Link> links = new System.Collections.Generic.List<Link> { };
            System.Collections.Generic.List<EmailProperty> empProps = new System.Collections.Generic.List<EmailProperty> { };


            Link link = new Link();
            link.Href = "http://api.aspose.com/v1.1/pdf/";
            link.Rel = "self";
            link.Title = "NewField";
            link.Type = "link";
            links.Add(link);


            EmailProperty emailBody = new EmailProperty();
            EmailProperty emailTo = new EmailProperty();
            EmailProperty emailFrom = new EmailProperty();

            emailBody.Name = "Body";
            emailBody.Value = "This is the Body";
            emailBody.Link = link;
            empProps.Add(emailBody);

            emailTo.Name = "To";
            emailTo.Value = "*****@*****.**";
            emailTo.Link = link;
            empProps.Add(emailTo);

            emailFrom.Name = "From";
            emailFrom.Value = "*****@*****.**";
            emailFrom.Link = link;
            empProps.Add(emailFrom);


            emailProperties.List = empProps;
            emailProperties.Link = link;

            body.DocumentProperties = emailProperties;
            body.Links = links;
            
            storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\email\\resources\\" + name)); 
            
            EmailDocumentResponse actual;
            actual = target.PutCreateNewEmail(name, storage, folder, body);
            
            Assert.AreEqual("200", actual.Code);
            Assert.IsInstanceOfType(new EmailDocumentResponse(), actual.GetType()); 
        }