Save the email as pdf in Sharepoint 2016 document Library using c#

Athulya Pillai 1 Reputation point
2023-06-06T09:42:18.91+00:00

Hello Team,

I need to read the email and save as pdf in SharePoint 2016 doc library using c#

I am reading the email using MSgraph api and but facing problem in saving the eml file as pdf

Thanks

Athulya

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,223 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ChengFeng - MSFT 5,040 Reputation points Microsoft Vendor
    2023-06-07T06:32:31.1266667+00:00

    Hi @Athulya Pillai,

    To convert files to PDF and upload them to SharePoint 2016, various methods and tools are available. You can consider the following options:

    iTextSharp: iTextSharp is a popular open source library for programmatically creating and manipulating PDF files in .NET. You can use iTextSharp to convert files to PDF format in custom .NET applications. Once the conversion is complete, you can upload the PDF file to SharePoint 2016 utilizing SharePoint's Client Side Object Model (CSOM) or REST API

    Power Automate: As mentioned earlier, you can leverage Power Automate to create workflows that automatically convert files to PDF and upload them to SharePoint 2016. You can use the available connectors and actions to perform the transformation and SharePoint upload steps. Power Automate provides a visual interface for designing workflows without coding.

    The choice of method depends on your specific requirements, technical expertise and available resources. If you prefer a more customizable solution or have complex requirements, using iTextSharp or developing a custom application may be the best option.

    Using the iTextSharp library in Visual Studio can be done as follows:Download the iTextSharp library:

    You can download the latest version of iTextSharp from https://github.com/itext/itextsharp.

    Extract the downloaded file.Create a new project or open an existing project in Visual Studio.

    In Solution Explorer, right-click the project name and select Manage NuGet Packages.In the NuGet Package Manager window, click the Browse tab.

    Type "itextsharp" in the search box and press Enter to search.Find the "iTextSharp" package in the search results, and click the "Install" button on the right to add the iTextSharp library to the project.

    Here are some link about how to use iTextSharp to convert to PDF for your reference:

    https://stackoverflow.com/questions/30197673/how-to-use-itextsharp-to-convert-to-pdf?rq=3

    https://stackoverflow.com/questions/4471376/creation-of-pdf-file-using-itextsharp?rq=3

    Here is a link about csom upload file to document library for your reference:

    https://daoudisamir.com/from-c-to-sharepoint-file-upload-using-csom-with-subfolders-structure/


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.