Inserting HTML Into OneNote

Home / c# / Inserting HTML Into OneNote

Question:
I’m trying to transfer information from a Word Document to a OneNote document. I got the html which made up the contents of a word document, but I want to take that html that was generated and store that into a OneNote file.

I have tried things like the OneNote API and the Microsoft Graph API, but is there a way to do this without using those API tools? Here is the code I have for generating the HTML from a word document.
byte[] byteArray = File.ReadAllBytes("GreetingFile2.docx");
using (MemoryStream memoryStream = new MemoryStream())
{
memoryStream.Write(byteArray, 0, byteArray.Length);
using (WordprocessingDocument doc = WordprocessingDocument.Open(memoryStream, true))
{
HtmlConverterSettings settings = new HtmlConverterSettings()
{
PageTitle = "My Page Title"
};
XElement html = HtmlConverter.ConvertToHtml(doc, settings);

File.WriteAllText("‪Something.html", html.ToStringNewLineOnAttributes());
}
}
Thanks!


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *