Beispiel #1
0
        /// <summary>
        /// Registers Aspose Email License. Configure section 'Aspose-EmailLicense' in appsettings.json
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        public static void AddAsposeMailLicense(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            var license = new Aspose.Email.License();

            try
            {
                // Initializes a license from a stream
                var licenseInfo = configuration.GetSection("Aspose-EmailLicense").Value;
                if (String.IsNullOrWhiteSpace(licenseInfo))
                {
                    return;
                }
                var info = Encoding.UTF8.GetBytes(licenseInfo);
                using (var stream = new MemoryStream(info))
                {
                    license.SetLicense(stream);
                    Console.WriteLine("Aspose Email License set successfully.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"There was an error setting the Aspose Email License. Exception Message: {e.Message}");
                throw;
            }
        }
Beispiel #2
0
        private static void SetAsposeLicense()
        {
            var W = new License();

            W.SetLicense(ConfigurationManager.AppSettings["AsposeWords"]);

            var E = new Aspose.Email.License();

            E.SetLicense(ConfigurationManager.AppSettings["AsposeEmail"]);
        }
 private static void LoadLicense(string ext)
 {
     switch (ext)
     {
         case ".PDF":
             var pdfLicense = new Aspose.Pdf.License();
             pdfLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".DOC":
         case ".DOCX":
         case ".RTF":
             var docLicense = new Aspose.Words.License();
             docLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".XLS":
         case ".XLSX":
         case ".CSV":
             var xlsLicense = new Aspose.Cells.License();
             xlsLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".PPT":
         case ".PPTX":
             var pptLicense = new Aspose.Slides.License();
             pptLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".VSD":
         case ".VSDX":
             var vsdLicense = new Aspose.Diagram.License();
             vsdLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".MSG":
             var emaiLicense = new Aspose.Email.License();
             var msgPdfLicense = new Aspose.Words.License();
             emaiLicense.SetLicense("Aspose.Total.lic");
             msgPdfLicense.SetLicense("Aspose.Total.lic");
             break;
         default:
             var license = new Aspose.Words.License();
             license.SetLicense("Aspose.Total.lic");
             break;
     }
 }
Beispiel #4
0
 ///<Summary>
 /// SetAsposeEmailLicense method to Aspose.Email License
 ///</Summary>
 public static void SetAsposeEmailLicense()
 {
     Aspose.Email.License acLic = new Aspose.Email.License();
     acLic.SetLicense("Aspose.Total.lic");
 }