protected void CreateEnvelope()
        {
            // Create the envelope information
            DocuSignAPI.EnvelopeInformation envelopeInfo = new DocuSignAPI.EnvelopeInformation();
            envelopeInfo.Subject = Request.Form["subject"];
            envelopeInfo.EmailBlurb = Request.Form["emailBlurb"];
            envelopeInfo.AccountId = Session["APIAccountId"].ToString();

            // Add any reminders
            if (!String.IsNullOrEmpty(Request.Form["reminders"]))
            {
                DateTime remind = Convert.ToDateTime(Request.Form["reminders"]);
                int difference = (remind - DateTime.Today).Days;

                if (envelopeInfo.Notification == null)
                {
                    envelopeInfo.Notification = new DocuSignAPI.Notification();
                }
                envelopeInfo.Notification.Reminders = new DocuSignAPI.Reminders();
                envelopeInfo.Notification.Reminders.ReminderEnabled = true;
                envelopeInfo.Notification.Reminders.ReminderDelay = difference.ToString();
                envelopeInfo.Notification.Reminders.ReminderFrequency = "2";
            }

            // Add any expirations
            if (!String.IsNullOrEmpty(Request.Form["expiration"]))
            {
                DateTime expire = Convert.ToDateTime(Request.Form["expiration"]);
                int difference = (expire - DateTime.Today).Days;

                if (envelopeInfo.Notification == null)
                {
                    envelopeInfo.Notification = new DocuSignAPI.Notification();
                }

                envelopeInfo.Notification.Expirations = new DocuSignAPI.Expirations();
                envelopeInfo.Notification.Expirations.ExpireEnabled = true;
                envelopeInfo.Notification.Expirations.ExpireAfter = difference.ToString();
                envelopeInfo.Notification.Expirations.ExpireWarn = (difference - 2).ToString();
            }

            // Get all the recipients
            DocuSignAPI.Recipient[] recipients = ConstructRecipients();

            // Construct the template reference
            DocuSignAPI.TemplateReference templateReference = new DocuSignAPI.TemplateReference();
            templateReference.TemplateLocation = DocuSignAPI.TemplateLocationCode.Server;
            templateReference.Template = TemplateTable.Value;
            templateReference.RoleAssignments = CreateFinalRoleAssignments(recipients);

            if (Request.Form["SendNow"] != null)
            {
                SendNow(templateReference, envelopeInfo, recipients);
            }
            else
            {
                EmbedSending(templateReference, envelopeInfo, recipients);
            }
        }
        protected void CreateEnvelope()
        {
            // Create the envelope information
            var envelopeInfo = new DocuSignAPI.EnvelopeInformation
                {
                    Subject = Request.Form[Keys.Subject],
                    EmailBlurb = Request.Form[Keys.EmailBlurb],
                    AccountId = Session[Keys.ApiAccountId].ToString()
                };

            // Add any reminders
            if (!String.IsNullOrEmpty(Request.Form[Keys.Reminders]))
            {
                DateTime remind = Convert.ToDateTime(Request.Form[Keys.Reminders]);
                int difference = (remind - DateTime.Today).Days;

                if (null == envelopeInfo.Notification)
                {
                    envelopeInfo.Notification = new DocuSignAPI.Notification();
                }
                envelopeInfo.Notification.Reminders = new DocuSignAPI.Reminders
                    {
                        ReminderEnabled = true,
                        ReminderDelay = difference.ToString(),
                        ReminderFrequency = "2"
                    };
            }

            // Add any expirations
            if (!String.IsNullOrEmpty(Request.Form[Keys.Expiration]))
            {
                DateTime expire = Convert.ToDateTime(Request.Form[Keys.Expiration]);
                int difference = (expire - DateTime.Today).Days;

                if (null == envelopeInfo.Notification)
                {
                    envelopeInfo.Notification = new DocuSignAPI.Notification();
                }

                envelopeInfo.Notification.Expirations = new DocuSignAPI.Expirations
                    {
                        ExpireEnabled = true,
                        ExpireAfter = difference.ToString(),
                        ExpireWarn = (difference - 2).ToString()
                    };
            }

            // Get all the recipients
            var recipients = ConstructRecipients();

            // Construct the template reference
            var templateReference = new DocuSignAPI.TemplateReference
                {
                    TemplateLocation = DocuSignAPI.TemplateLocationCode.Server,
                    Template = TemplateTable.Value,
                    RoleAssignments = CreateFinalRoleAssignments(recipients)
                };

            if (null != Request.Form[Keys.SendNow])
            {
                SendNow(templateReference, envelopeInfo, recipients);
            }
            else //Edit
            {
                EmbedSending(templateReference, envelopeInfo, recipients);
            }
        }