How To Send Estimate From Quickbooks Online Using C#

In this blog, I will explain how to send an estimate from .NET MVC web application using SDK.

Before using any Quickbooks online API we need access token, if you don’t know how to get access token then you can find it here.

An estimate will be sent to the email. if the email address already set in estimate Email or it already exists in estimate’s “Estimate.BillEmail.Address” then it will be sent to that email else we have to give a particular email on which we have to send an estimate.

Below are a few steps to send an estimate,

  • First, we have to create a ServiceContext with Auth tokens and realmId.
  • For that, we need access token and realmId
  • We have to get the estimate from Quickbooks online by calling Estimate API.
  • We are querying an estimate by ID.
  • For querying/get estimate we have to define QueryService
  • We need to pass the ServiceContext object into QueryService.
  • We will get estimate details in objEstimateFound if there is an estimate that exists with ID.
  • After that, We have to create a DataService object by passing a ServiceContext object as a parameter.
  • Now, we will check the email address in the objEstimateFound object.
  • If the email exists then, add objEstimateFound object in dataService.SendEmail<Estimate>() for sending an estimate.
  • If an email does not exist, add objEstimateFound object and email in dataService.SendEmail<Estimate>() as a parameter for sending an estimate. we have to give an email on which we want to send an estimate. this will also update email in estimate so next time we don’t need to add email manually.
  • code is as below,
 public ActionResult SendEstimateById(string EstimateID)
    OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_token);

    // Create a ServiceContext with Auth tokens and realmId
    ServiceContext serviceContext = new ServiceContext(RealmId, IntuitServicesType.QBO, oauthValidator);
    serviceContext.IppConfiguration.MinorVersion.Qbo = "23";
    serviceContext.IppConfiguration.BaseUrl.Qbo = QboBaseUrl;

    string EXISTING_ESTIMATE_QUERYBYID = string.Format("select * from Estimate where id = '{0}'", EstimateID);
    var queryService = new QueryService<Estimate>(serviceContext);
    Estimate objEstimateFound = queryService.ExecuteIdsQuery(EXISTING_ESTIMATE_QUERYBYID).FirstOrDefault<Estimate>();

    //If Estimate found on Quickbooks online
    if (objEstimateFound != null)
        DataService dataService = new DataService(serviceContext);

        if (objEstimateFound.BillEmail != null)
            var SentPDF = dataService.SendEmail<Estimate>(objEstimateFound);
            ViewBag.IsSuccess = true;
            //if you want to then, you can set ToEmail from database or somewhere else
            String ToEmail = "";
            var SentPDF = dataService.SendEmail<Estimate>(objEstimateFound, ToEmail);
            ViewBag.IsSuccess = true;
    return View();
  catch (IdsException ex)
    return View();
  catch (Exception ex)
    return View();
  • View Code is as below,
    ViewBag.Title = "SendEstimateById";


@if (ViewBag.IsSuccess != null && ViewBag.IsSuccess == true)
    <div class="row">
        <label class="label label-success"> Estimate Sent Successfully </label>
  • The above code will send an estimate to email.

You can also set a send email link in the list view of the estimate. if you don’t know how to get estimates from Quickbooks Online you can find it here.

  • View Code(cshtml) of the estimate list with the Send email link is as below.
@model List<Intuit.Ipp.Data.Estimate>

    ViewBag.Title = "GetAllEstimate";

<h2>Quickbooks online Estimate List</h2>

    <table class="table table-bordered">
            <th>QBO ID</th>
            <th>Estimate Number</th>
            <th>Due Date</th>
            <th>Total Amount</th>
            <th style="text-align:center;">Download</th>
            <th style="text-align:center;">Send Email</th>

        @foreach (var item in Model)
                <td style="text-align:center;"><a href="@Url.Action("GetEstimatePdfById", "Home", new { EstimateID = item.Id })" target="_blank"><img src="~/Content/Images/downloadICON.png" height="25" width="25" /></a></td>
                <td style="text-align:center;"><a href="@Url.Action("SendEstimateById", "Home", new { EstimateID = item.Id })" target="_blank"><img src="~/Content/Images/SendImageICON.png" height="25" width="25" /></a></td>


In the above code, on click of send email icon estimate will be sent.


  • Estimate List

  • View of SendEstimateById


Submit a Comment

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


Select Categories