none
Approving item from outlook to SQL DB in Provider Hosted add-in RRS feed

  • Question

  • Hi,

    In my SharePoint Provider Hosted add-in (ASP.NET MVC 5), i am sending email notification to people to approve the item on outlook email. Right now, the approver gets a link to the item and login to the application to approve it.

    What I want to do is, the approvers will get another link called "Approve Item" with the email notification to their outlook email box and just click the "Approve Item" link which will send a value "approved" to the SQL database, they don't need to login to the app to approve.

    Any idea how could I achieve this?

    Thanks in advance.

    Monday, March 11, 2019 8:41 AM

Answers

  • Hi pointtoshare,

    1. Yes, send email method is written in code behind using C# SmtpClient class, from html button onclick event, only call the code behind method with ajax, this is not related to JavaScript.

    2. The email html templated is created and used as email body, not need to redirect, once user receive the email, the email body will be the html template, please check the demo in the first and second link.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, March 12, 2019 8:50 AM

All replies

  • Hi,

    Any idea or suggestion?

    Thanks.

    Monday, March 11, 2019 4:56 PM
  • Hi pointtoshare,

    Is it a approval workflow or something else ? And want to approve a list item or directly consume SQL Database ?

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, March 12, 2019 6:45 AM
  • Hi Jerry,

    Thanks for your reply.

    I am not using SharePoint List, using SQL Database instead for storing data. 

    For approval, I am putting value to "Status" field in the database table for that particular item, for example, if Approved its 1, if rejected its 0.

    I want to do, sending two buttons or links for Approve and Reject with the email notification on email body. If Approve is clicked it will update the relevant database table Status field to 1, if Reject is clicked it will update Status field to 0. But, the user will not login to the app for this action. 

    Please advise.

    Thanks.

    Tuesday, March 12, 2019 6:57 AM
  • Hi pointtoshare,

    You could create a spearate html email template with button or hyperlink and then read the html file as Bytes, used in mail.Body:

    Send Emails By Using Email Templates in ASP.NET MVC using C#

    Walkthrough: Creating an HTML Email Template with Razor and Razor Class Libraries and Rendering it from a .NET Standard Class Library

    And in the html button, could call the C# code behind method to update Database:

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    	<meta charset="utf-8" />
        <script src="Scripts/jquery-1.10.2.js"></script>
        <script type="text/javascript">
            // Ajax call using jquery to your website's page
            function callAjax(actiontype) {
                var request = $.ajax({ url: "http://yoururl/webform1.aspx", method: "GET", data: { paramvalue: actiontype }, dataType: "html" });
            }
        </script>
    </head>
    <body>
        <input type="button"  onclick="callAjax('Accept');" value="Accept" />
        <input type="button" onclick="callAjax('Reject');" value="Reject" />
    </body>
    </html>

    Updating database on button click from email body

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, March 12, 2019 7:31 AM
  • Hi Jerry,

    Thanks again.

    The last link- https://forums.asp.net/t/2069403.aspx?Updating+database+on+button+click+from+email+body

    said email clients doesn't support JavaScript. I am wondering if it will works for me.

    Another thing is, I don't want user to be redirected to the web page, is it possible in this guides?

    Thanks.

    Tuesday, March 12, 2019 8:43 AM
  • Hi pointtoshare,

    1. Yes, send email method is written in code behind using C# SmtpClient class, from html button onclick event, only call the code behind method with ajax, this is not related to JavaScript.

    2. The email html templated is created and used as email body, not need to redirect, once user receive the email, the email body will be the html template, please check the demo in the first and second link.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, March 12, 2019 8:50 AM
  • Ok, let me try and get back to you. Thanks.
    Tuesday, March 12, 2019 9:04 AM
  • Hi,

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

    You can mark the helpful post as answer to help other community members find the helpful information quickly. 

    Thanks

    Best Regards

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, March 18, 2019 5:53 AM