|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.IO; |
| 4 | +using GroupDocs.Conversion.Options.Convert; |
| 5 | +using GroupDocs.Conversion.Options.Load; |
| 6 | + |
| 7 | +namespace GroupDocs.Conversion.Examples.CSharp.AdvancedUsage |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// This example demonstrates how to convert an email document and localize email fields |
| 11 | + /// </summary> |
| 12 | + internal static class ConvertEmailWithLocalizingEmailFields |
| 13 | + { |
| 14 | + public static void Run() |
| 15 | + { |
| 16 | + string outputFolder = Constants.GetOutputDirectoryPath(); |
| 17 | + string outputFile = Path.Combine(outputFolder, "converted.pdf"); |
| 18 | + |
| 19 | +#if NETCOREAPP |
| 20 | + Func<LoadOptions> getLoadOptions = () => new EmailLoadOptions |
| 21 | + { |
| 22 | + FieldTextMap = new Dictionary<EmailField, string> |
| 23 | + { |
| 24 | + {EmailField.Subject, "Gegenstand"}, |
| 25 | + {EmailField.From, "Von"}, |
| 26 | + {EmailField.Attachments, "Anhänge"} |
| 27 | + } |
| 28 | + }; |
| 29 | +#else |
| 30 | + Contracts.Func<LoadOptions> getLoadOptions = () => new EmailLoadOptions |
| 31 | + { |
| 32 | + FieldTextMap = new Dictionary<EmailField, string> |
| 33 | + { |
| 34 | + { EmailField.Subject, "Gegenstand" }, |
| 35 | + { EmailField.From, "Von" }, |
| 36 | + { EmailField.Attachments, "Anhänge" } |
| 37 | + } |
| 38 | + }; |
| 39 | +#endif |
| 40 | + using (Converter converter = new Converter(Constants.SAMPLE_EML, getLoadOptions)) |
| 41 | + { |
| 42 | + PdfConvertOptions options = new PdfConvertOptions(); |
| 43 | + converter.Convert(outputFile, options); |
| 44 | + } |
| 45 | + |
| 46 | + Console.WriteLine("\nEmail document converted successfully. \nCheck output in {0}", outputFolder); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
0 commit comments