diff --git a/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer.sln b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer.sln new file mode 100644 index 000000000..700f91447 --- /dev/null +++ b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mail-merge-in-textbox-header-footer", "Mail-merge-in-textbox-header-footer\Mail-merge-in-textbox-header-footer.csproj", "{D3AF529E-DB54-4294-A876-DD42E1E472D0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58137FF9-5AE1-4514-9929-3A8A7DA1DFEB} + EndGlobalSection +EndGlobal diff --git a/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Data/Template.docx b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Data/Template.docx new file mode 100644 index 000000000..dfd78a7e6 Binary files /dev/null and b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Data/Template.docx differ diff --git a/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Mail-merge-in-textbox-header-footer.csproj b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Mail-merge-in-textbox-header-footer.csproj new file mode 100644 index 000000000..6c5b5049a --- /dev/null +++ b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Mail-merge-in-textbox-header-footer.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + Mail_merge_in_textbox_header_footer + + + + + + + + + Always + + + Always + + + + diff --git a/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Output/.gitkeep b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Program.cs b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Program.cs new file mode 100644 index 000000000..0d180153d --- /dev/null +++ b/Mail-Merge/Mail-merge-in-textbox-header-footer/.NET/Mail-merge-in-textbox-header-footer/Program.cs @@ -0,0 +1,32 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using System.IO; + +namespace Mail_merge_in_textbox_header_footer +{ + class Program + { + static void Main(string[] args) + { + + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.ReadWrite)) + { + //Loads an existing Word document into DocIO instance. + using (WordDocument document = new WordDocument(fileStream, FormatType.Automatic)) + { + string[] fieldNames = new string[] { "HeaderContent", "ProductName1", "ProductName2" }; + string[] fieldValues = new string[] { "Adventure Works Cycles", "Mountain-200", "Mountain-300" }; + //Performs the mail merge + document.MailMerge.Execute(fieldNames, fieldValues); + + //Creates file stream. + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Saves the Word document to file stream. + document.Save(outputStream, FormatType.Docx); + } + } + } + } + } +}